43 #include <sys/types.h> 48 __clib_export __thread
uword __os_thread_index = 0;
49 __clib_export __thread
uword __os_numa_index = 0;
56 if (stat (file, &s) < 0)
59 if (S_ISREG (s.st_mode))
75 if ((fd = open (file, 0)) < 0)
83 if ((n_read = read (fd, v + n_done, n_left)) < 0)
101 " `%s' expected to read %wd bytes; read only %wd",
102 file, n_bytes, n_bytes - n_left);
142 fd = open (file, O_RDONLY);
151 bytes = read (fd, rv + pos, 4096);
172 void os_panic (
void) __attribute__ ((weak));
180 void os_exit (
int) __attribute__ ((weak));
189 __attribute__ ((weak));
197 int fd = is_error ? 2 : 1;
198 struct iovec iovs[2];
203 snprintf (buf,
sizeof (buf),
"%d: ", cpu);
205 iovs[n_iovs].iov_base = buf;
206 iovs[n_iovs].iov_len = strlen (buf);
210 iovs[n_iovs].iov_base =
string;
211 iovs[n_iovs].iov_len = string_length;
214 if (writev (fd, iovs, n_iovs) < 0)
218 __clib_export __clib_weak
void 224 __clib_export __clib_weak
uword #define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
__clib_export __clib_weak void os_out_of_memory(void)
#define clib_error_return(e, args...)
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
__clib_export clib_error_t * clib_file_contents(char *file, u8 **result)
#define clib_error_return_unix(e, args...)
#define vec_free(V)
Free vector's memory (no header).
clib_error_t * clib_file_read_contents(char *file, u8 *result, uword n_bytes)
void os_puts(u8 *string, uword string_length, uword is_error)
__clib_export __clib_weak uword os_get_nthreads(void)
clib_error_t * unix_proc_file_contents(char *file, u8 **result)
static_always_inline uword os_get_thread_index(void)
clib_error_t * clib_file_n_bytes(char *file, uword *result)