1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
/**
* Copyright (C) Mellanox Technologies Ltd. 2001-2014. ALL RIGHTS RESERVED.
* Copyright (c) UT-Battelle, LLC. 2014-2019. ALL RIGHTS RESERVED.
* Copyright (C) ARM Ltd. 2016. ALL RIGHTS RESERVED.
*
* See file LICENSE for terms.
*/
typedef cpu_set_t ucs_sys_cpuset_t;
typedef cpuset_t ucs_sys_cpuset_t;
/** @file sys.h */
typedef ino_t ucs_sys_ns_t;
/* namespace type used in @ref ucs_sys_get_ns and @ref ucs_sys_ns_is_default */
typedef enum ucs_sys_namespace_type_t;
/* virtual memory area flags */
typedef enum ucs_sys_vma_info_flags_t;
/* information about virtual memory area */
typedef struct ucs_sys_vma_info_t;
/**
* Callback function type used in ucs_sys_iterate_vm.
*/
typedef void ;
/**
* Callback function type used in ucs_sys_readdir.
*/
typedef ;
/**
* Callback function type used in ucs_sys_enum_threads.
*/
typedef ;
/**
* Callback function type used in ucs_sys_enum_pfn.
*/
typedef void ;
/**
* @return TMPDIR environment variable if set. Otherwise, return "/tmp".
*/
const char *;
/**
* @return Host name.
*/
const char *;
/**
* @return user name.
*/
const char *;
/**
* Expand a partial path to full path.
*
* @param path Path to expand.
* @param fullpath Filled with full path.
* @param max Room in "fullpath"
*/
void ;
/**
* @return Path to the main executable.
*/
const char *;
/**
* Calculate checksum of a file.
*/
uint32_t ;
/**
* Get a globally unique identifier of the machine running the current process.
*/
uint64_t ;
/**
* Get the first processor number we are bound to.
*/
int ;
/**
* Generate a world-wide unique ID
*
* @param seed Additional seed to mix in.
*
* @note All bits of the returned number have the same randomness.
*/
uint64_t ;
/**
* Returns a value one greater than the maximum file descriptor
* number that can be opened by this process. Attempts to exceed
* this limit yield the error EMFILE.
*
* @return The maximal number of files that could be opened simultaneously.
*/
int ;
/**
* Open an output stream according to user configuration:
* - file:<name> - file name, %p, %h, %c are substituted.
* - stdout
* - stderr
*
* @param [in] config_str The file name or name of the output stream
* (stdout/stderr).
* @param [in] err_log_level Logging level that should be used for printing
* errors.
* @param [out] p_fstream Pointer that is filled with the stream handle.
* User is responsible to close tha stream handle then.
* @param [out] p_need_close Pointer to the variable that is set to whether
* fclose() should be called to release resources (1)
* or not (0).
* @param [out] p_next_token Pointer that is set to remainder of @config_str.
* @param [out] p_filename Pointer to the variable that is filled with the
* resulted name of the log file (if it is not NULL).
* Caller is responsible to release memory then.
*
* @return UCS_OK if successful, or error code otherwise.
*/
ucs_status_t
;
/**
* Read file contents into a string. If the size of the data is smaller than the
* supplied upper limit (max), a null terminator is appended to the data.
*
* @param buffer Buffer to fill with file contents.
* @param max Maximal buffer size.
* @param filename_fmt File name printf-like format string.
*
* @return Number of bytes read, or -1 in case of error.
*/
ssize_t ;
/**
* Read file contents as a numeric value.
*
* @param value Filled with the number read from the file.
* @param filename_fmt File name printf-like format string.
*
* @return UCS_OK if successful, or error code otherwise.
*/
ucs_status_t ;
/**
* Read file contents into a string closed by null terminator.
*
* @param buffer Buffer to fill with file contents.
* @param max Maximal buffer size.
* @param filename_fmt File name printf-like format string.
*
* @return Number of bytes read, or -1 in case of error.
*/
ssize_t ;
/**
* @return Regular page size on the system.
*/
size_t ;
/**
* Get info for memory range.
*
* @param address Memory range start address,
* @param size Memory range size.
* @param cb Callback function which is called for every vm area.
* @param ctx Context argument passed to @a cb call.
*/
void ;
/**
* Get page size of a memory range.
*
* @param [in] address Memory range start address,
* @param [in] size Memory range size.
* @param [out] min_page_size_p Set to the minimal page size in the memory range.
* @param [out] max_page_size_p Set to the maximal page size in the memory range.
*/
void ;
/**
* @return Huge page size on the system, or -1 if unsupported.
*/
ssize_t ;
/**
* @return free mem size on the system.
*/
size_t ;
/**
* @return Physical memory size on the system.
*/
size_t ;
/**
* Allocate shared memory using SystemV API.
*
* @param size Pointer to memory size to allocate, updated with actual size
* (rounded up to huge page size or to regular page size).
* @param max_size maximal size to allocate. If need to allocate more than this,
* the function fails and returns UCS_ERR_EXCEEDS_LIMIT.
* @param address_p Filled with allocated memory address.
* @param flags Flags to indicate the permissions for the allocate memory.
* (also, whether or not to allocate memory with huge pages).
* @param alloc_name Name of memory allocation, for debug/error reporting purposes.
* @param shmid Filled with the shmid from the shmget call in the function.
*/
ucs_status_t ;
/**
* Release memory allocated via SystemV API.
*
* @param address Memory to release (returned from @ref ucs_sysv_alloc).
*/
ucs_status_t ;
/**
* Allocate private memory using mmap API.
*
* @param size Pointer to memory size to allocate, updated with actual size
* (rounded up to huge page size or to regular page size).
* @param address_p Filled with allocated memory address.
* @param flags Flags to pass to the mmap() system call
*/
ucs_status_t ;
/**
* Release memory allocated via mmap API.
*
* @param address Address of memory to release as returned from @ref ucs_mmap_alloc.
* @param length Length of memory to release passed to @ref ucs_mmap_alloc.
*/
ucs_status_t ;
/**
* Retrieve memory access flags for a given region of memory.
* If the specified memory region has multiple different access flags, the AND
* of them is returned. If any part of the region is not mapped, PROT_NONE will
* be returned.
*
* @param start Region start.
* @param end Region end.
* @return Memory protection flags (PROT_xxx).
*/
int ;
/**
* Returns the physical page frame number of a given virtual page address.
* If the page map file is non-readable (for example, due to permissions), or
* the page is not present, this function returns 0.
*
* @param address Virtual address to get the. PFN for.
* @param page_count Number of pages to process
* @param data Result buffer.
* @return UCS_OK if all pages are processed, else error code.
*/
ucs_status_t ;
/**
* Enums the physical page frame numbers of a given virtual address range.
* If the page map file is non-readable (for example, due to permissions), or
* the page is not present, this function returns error.
*
* @param address Virtual address to get the PFN for.
* @param page_number Number of pages to process.
* @param cb Callback function which is called for every page.
* @param ctx Context argument passed to @a cb call.
* @return error code if failed to enumerate or UCS_OK.
*/
ucs_status_t ;
/**
* Modify file descriptor flags via fcntl().
*
* @param fd File descriptor to modify.
* @param add Flags to add.
* @param remove Flags to remove.
*
* Note: if a flags is specified in both add and remove, it will be removed.
*/
ucs_status_t ;
/**
* Get process command line
*/
const char* ;
/**
* Get current thread (LWP) id.
*/
pid_t ;
/**
* Send signal to a thread.
*/
int ;
/**
* Get CPU frequency from /proc/cpuinfo. Return value is clocks-per-second.
*
* @param header String in /proc/cpuinfo which precedes the clock speed number.
* @param scale Frequency value units.
*/
double ;
/**
* Check if transparent huge-pages are enabled .
*
* @return 1 for true and 0 for false
*/
int ;
/**
* Get shmmax size from /proc/sys/kernel/shmmax.
*
* @return shmmax size
*/
size_t ;
/**
* Return effective capabilities of the current thread.
*
* @param effective Filled with thread's effective capabilities.
* @return UCS_OK or error in case of failure.
*/
ucs_status_t ;
/**
* Allocate or re-allocate memory from the operating system.
*
* @param [in] old_ptr Pointer to existing block, may be NULL. If non-NULL,
* this block will be resized and potentially moved.
* @param [in] old_length Length of the block pointed by old_ptr.
* @param [in] new_length Length to allocate for the new block.
*
* @return New allocated block, with size 'new_length'.
* @note Actual allocation size is rounded up to system page size.
*/
void *;
/**
* Release memory previously allocated by @ref ucs_sys_realloc().
*
* @param [in] ptr Pointer to memory block to release.
* @param [in] length Length of the memory block.
*/
void ;
/**
* Fill human readable cpu set representation
*
* @param [in] cpuset Set of CPUs
* @param [in] str String to fill
* @param [in] len String length
*
* @return Filled string
*/
char *;
/**
* Sets affinity for the current process.
*
* @param [in] cpuset Pointer to the cpuset to assign
*
* @return -1 on error with errno set, 0 on success
*/
int ;
/**
* Queries affinity for the current process.
*
* @param [out] cpuset Pointer to the cpuset to return result
*
* @return -1 on error with errno set, 0 on success
*/
int ;
/**
* Copies ucs_sys_cpuset_t to ucs_cpu_set_t.
*
* @param [in] src Source
* @param [out] dst Destination
*/
void ;
/**
* Get namespace id for resource.
*
* @param [in] name Namespace to get value
*
* @return namespace value or 0 if namespaces are not supported
*/
ucs_sys_ns_t ;
/**
* Check if namespace is namespace of host system.
*
* @param [in] name Namespace to evaluate
*
* @return 1 in case if namespace is root, 0 - in other cases
*/
int ;
/**
* Get 128-bit boot ID value.
*
* @param [out] high Pointer to high 64 bit of 128 boot ID
* @param [out] low Pointer to low 64 bit of 128 boot ID
*
* @return UCS_OK or error in case of failure.
*/
ucs_status_t ;
/**
* Read directory
*
* @param [in] path Path to directory to read
* @param [in] cb Callback function, see NOTES
* @param [in] ctx Context pointer passed to callback
*
* @return UCS_OK if directory is found and successfully iterated thought all
* entries, error code in all other cases, see NOTES.
*
* @note ucs_sys_readdir function reads directory pointed by @a path argument
* and calls @a cb function for every entry in directory, including
* '.' and '..'. In case if @a cb function returns value different from
* UCS_OK then function breaks immediately and this value is returned
* from ucs_sys_readdir.
*/
ucs_status_t ;
/**
* Enumerate process threads
*
* @param [in] cb Callback function, see NOTES
* @param [in] ctx Context pointer passed to callback
*
* @return UCS_OK if directory is found and successfully iterated thought all
* entries, error code in all other cases, see NOTES.
*
* @note ucs_sys_enum_threads function enumerates current process threads
* and calls @a cb function for every thread. In case if @a cb function
* returns value different from UCS_OK then function breaks
* immediately and this value is returned from ucs_sys_enum_threads.
*/
ucs_status_t ;
/**
* Check the per-process limit on the number of open file descriptors.
*
* @return UCS_OK if the limit has not been reached. UCS_ERR_EXCEEDS_LIMIT,
* otherwise.
*/
ucs_status_t ;
/*
* Create a named thread.
*
* @param [out] thread_id_p If successful, set to the new thread id.
* @param [in] start_routine Thread function.
* @param [in] arg Custom argument for start_routine.
* @param [in] fmt Thread name format string.
*
* @return UCS_OK if successful, or error status if failed.
*/
ucs_status_t ;
/*
* Get number of CPUs.
*
* @return number of CPUs, or -1 in case of error.
*/
long ;
/*
* Get process creation time.
*
* @param [in] pid Process id to get start time.
*
* @return The time the process started after system boot or 0 in case of error.
*/
unsigned long ;