ReactOS 0.4.15-dev-7961-gdcf9eb0
port.h File Reference
#include <fcntl.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
Include dependency graph for port.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  option
 

Macros

#define _GNU_SOURCE   /* for pread/pwrite, isfinite */
 
#define __int64   long long
 
#define RTLD_LAZY   0x001
 
#define RTLD_NOW   0x002
 
#define RTLD_GLOBAL   0x100
 
#define S_ISLNK(mod)   (0)
 
#define O_LARGEFILE   0
 
#define O_BINARY   0
 
#define M_PI   3.14159265358979323846
 
#define M_PI_2   1.570796326794896619
 
#define M_PI_4   0.785398163397448309616
 
#define INFINITY   __port_infinity()
 
#define NAN   __port_nan()
 
#define _P_WAIT   0
 
#define _P_NOWAIT   1
 
#define _P_OVERLAY   2
 
#define _P_NOWAITO   3
 
#define _P_DETACH   4
 
#define interlocked_cmpxchg   InterlockedCompareExchange
 
#define interlocked_cmpxchg_ptr   InterlockedCompareExchangePointer
 
#define interlocked_xchg   InterlockedExchange
 
#define interlocked_xchg_ptr   InterlockedExchangePointer
 
#define interlocked_xchg_add   InterlockedExchangeAdd
 
#define ffs   __builtin_ffs
 

Typedefs

typedef int mode_t
 
typedef long off_t
 
typedef int pid_t
 
typedef unsigned int size_t
 
typedef int ssize_t
 

Functions

static float __port_infinity (void)
 
static float __port_nan (void)
 
int getopt_long (int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind)
 
int getopt_long_only (int ___argc, char *const *___argv, const char *__shortopts, const struct option *__longopts, int *__longind)
 
size_t getpagesize (void)
 
int isfinite (double x)
 
int isinf (double x)
 
int isnan (double x)
 
int lstat (const char *file_name, struct stat *buf)
 
voidmemmove (void *dest, const void *src, size_t len)
 
ssize_t pread (int fd, void *buf, size_t count, off_t offset)
 
ssize_t pwrite (int fd, const void *buf, size_t count, off_t offset)
 
int statfs (const char *name, struct statfs *info)
 
int strncasecmp (const char *str1, const char *str2, size_t n)
 
const charstrerror (int err)
 
int strcasecmp (const char *str1, const char *str2)
 
int usleep (unsigned int useconds)
 
voidmemcpy_unaligned (void *dst, const void *src, size_t size)
 
int mkstemps (char *template, int suffix_len)
 
int spawnvp (int mode, const char *cmdname, const char *const argv[])
 

Variables

charoptarg
 
int optind
 
int opterr
 
int optopt
 

Macro Definition Documentation

◆ __int64

#define __int64   long long

Definition at line 58 of file port.h.

◆ _GNU_SOURCE

#define _GNU_SOURCE   /* for pread/pwrite, isfinite */

Definition at line 29 of file port.h.

◆ _P_DETACH

#define _P_DETACH   4

Definition at line 335 of file port.h.

◆ _P_NOWAIT

#define _P_NOWAIT   1

Definition at line 332 of file port.h.

◆ _P_NOWAITO

#define _P_NOWAITO   3

Definition at line 334 of file port.h.

◆ _P_OVERLAY

#define _P_OVERLAY   2

Definition at line 333 of file port.h.

◆ _P_WAIT

#define _P_WAIT   0

Definition at line 331 of file port.h.

◆ ffs

#define ffs   __builtin_ffs

Definition at line 359 of file port.h.

◆ INFINITY

#define INFINITY   __port_infinity()

Definition at line 162 of file port.h.

◆ interlocked_cmpxchg

#define interlocked_cmpxchg   InterlockedCompareExchange

Definition at line 343 of file port.h.

◆ interlocked_cmpxchg_ptr

#define interlocked_cmpxchg_ptr   InterlockedCompareExchangePointer

Definition at line 344 of file port.h.

◆ interlocked_xchg

#define interlocked_xchg   InterlockedExchange

Definition at line 345 of file port.h.

◆ interlocked_xchg_add

#define interlocked_xchg_add   InterlockedExchangeAdd

Definition at line 347 of file port.h.

◆ interlocked_xchg_ptr

#define interlocked_xchg_ptr   InterlockedExchangePointer

Definition at line 346 of file port.h.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 145 of file port.h.

◆ M_PI_2

#define M_PI_2   1.570796326794896619

Definition at line 149 of file port.h.

◆ M_PI_4

#define M_PI_4   0.785398163397448309616

Definition at line 153 of file port.h.

◆ NAN

#define NAN   __port_nan()

Definition at line 171 of file port.h.

◆ O_BINARY

#define O_BINARY   0

Definition at line 137 of file port.h.

◆ O_LARGEFILE

#define O_LARGEFILE   0

Definition at line 133 of file port.h.

◆ RTLD_GLOBAL

#define RTLD_GLOBAL   0x100

Definition at line 104 of file port.h.

◆ RTLD_LAZY

#define RTLD_LAZY   0x001

Definition at line 102 of file port.h.

◆ RTLD_NOW

#define RTLD_NOW   0x002

Definition at line 103 of file port.h.

◆ S_ISLNK

#define S_ISLNK (   mod)    (0)

Definition at line 128 of file port.h.

Typedef Documentation

◆ mode_t

typedef int mode_t

Definition at line 63 of file port.h.

◆ off_t

typedef long off_t

Definition at line 66 of file port.h.

◆ pid_t

typedef int pid_t

Definition at line 69 of file port.h.

◆ size_t

typedef unsigned int size_t

Definition at line 72 of file port.h.

◆ ssize_t

typedef int ssize_t

Definition at line 75 of file port.h.

Function Documentation

◆ __port_infinity()

static float __port_infinity ( void  )
inlinestatic

Definition at line 157 of file port.h.

158{
159 static const unsigned __inf_bytes = 0x7f800000;
160 return *(const float *)&__inf_bytes;
161}

◆ __port_nan()

static float __port_nan ( void  )
inlinestatic

Definition at line 166 of file port.h.

167{
168 static const unsigned __nan_bytes = 0x7fc00000;
169 return *(const float *)&__nan_bytes;
170}

◆ getopt_long()

int getopt_long ( int  ___argc,
char *const ___argv,
const char __shortopts,
const struct option __longopts,
int __longind 
)

Definition at line 283 of file getopt.c.

289{
290 int retval;
291
292 _DIAGASSERT(nargv != NULL);
295
296 if ((retval = getopt_internal(nargc,nargv,options)) == -2) {
297 char *current_argv,*has_equal;
298 size_t current_argv_len;
299 int i,match;
300
301 current_argv = place;
302 match = -1;
303
304 optind++;
305 place = EMSG;
306
307 if (*current_argv == '\0') {
308
309 if (nonopt_end != -1) {
312 }
314 return -1;
315 }
316 if ((has_equal = strchr(current_argv,'=')) != NULL) {
317
318 current_argv_len = has_equal - current_argv;
319 has_equal++;
320 } else
321 current_argv_len = strlen(current_argv);
322
323 for (i = 0; long_options[i].name; i++) {
324
325 if (strncmp(current_argv,long_options[i].name,current_argv_len))
326 continue;
327
328 if (strlen(long_options[i].name) ==
329 (unsigned)current_argv_len) {
330
331 match = i;
332 break;
333 }
334 if (match == -1)
335 match = i;
336 else {
337
338 if (PRINT_ERROR)
339 warnx(ambig,(int)current_argv_len,current_argv);
340 optopt = 0;
341 return BADCH;
342 }
343 }
344 if (match != -1) {
345 if (long_options[match].has_arg == no_argument
346 && has_equal) {
347 if (PRINT_ERROR)
348 warnx(noarg,(int)current_argv_len,current_argv);
349
350 if (long_options[match].flag == NULL)
352 else
353 optopt = 0;
354 return BADARG;
355 }
356 if (long_options[match].has_arg == required_argument ||
358 if (has_equal)
359 optarg = has_equal;
360 else if (long_options[match].has_arg ==
362
363 optarg = nargv[optind++];
364 }
365 }
366 if ((long_options[match].has_arg == required_argument)
367 && (optarg == NULL)) {
368
369 if (PRINT_ERROR)
370 warnx(recargstring,current_argv);
371
372 if (long_options[match].flag == NULL)
374 else
375 optopt = 0;
376 --optind;
377 return BADARG;
378 }
379 } else {
380 if (PRINT_ERROR)
381 warnx(illoptstring,current_argv);
382 optopt = 0;
383 return BADCH;
384 }
385 if (long_options[match].flag) {
386 *long_options[match].flag = long_options[match].val;
387 retval = 0;
388 } else
389 retval = long_options[match].val;
390 if (idx)
391 *idx = match;
392 }
393 return retval;
394}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define BADCH
Definition: getopt.c:51
int optopt
Definition: getopt.c:48
#define EMSG
Definition: getopt.c:52
const char * optarg
Definition: getopt.c:49
int optind
Definition: getopt.c:47
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
#define no_argument
Definition: getopt.h:122
#define required_argument
Definition: getopt.h:123
#define optional_argument
Definition: getopt.h:124
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define warnx(...)
static const char noarg[]
Definition: getopt.c:63
static const char recargstring[]
Definition: getopt.c:61
static int getopt_internal(int, char *const *, const char *)
Definition: getopt.c:137
static const char illoptstring[]
Definition: getopt.c:65
static int nonopt_start
Definition: getopt.c:57
static char * place
Definition: getopt.c:55
static int nonopt_end
Definition: getopt.c:58
static void permute_args(int, int, int, char *const *)
Definition: getopt.c:103
#define PRINT_ERROR
Definition: getopt.c:35
#define BADARG
Definition: getopt.c:46
static const char ambig[]
Definition: getopt.c:62
#define _DIAGASSERT(x)
Definition: getopt.c:11
Definition: match.c:28
Definition: name.c:39
static const struct option long_options[]
Definition: widl.c:185

◆ getopt_long_only()

int getopt_long_only ( int  ___argc,
char *const ___argv,
const char __shortopts,
const struct option __longopts,
int __longind 
)

◆ getpagesize()

size_t getpagesize ( void  )

◆ isfinite()

int isfinite ( double  x)

◆ isinf()

int isinf ( double  x)

◆ isnan()

int isnan ( double  x)

◆ lstat()

int lstat ( const char file_name,
struct stat buf 
)

◆ memcpy_unaligned()

void * memcpy_unaligned ( void dst,
const void src,
size_t  size 
)

◆ memmove()

void * memmove ( void dest,
const void src,
size_t  len 
)

Definition at line 8 of file memmove.c.

9{
10 char *char_dest = (char *)dest;
11 char *char_src = (char *)src;
12
13 if ((char_dest <= char_src) || (char_dest >= (char_src+count)))
14 {
15 /* non-overlapping buffers */
16 while(count > 0)
17 {
18 *char_dest = *char_src;
19 char_dest++;
20 char_src++;
21 count--;
22 }
23 }
24 else
25 {
26 /* overlaping buffers */
27 char_dest = (char *)dest + count - 1;
28 char_src = (char *)src + count - 1;
29
30 while(count > 0)
31 {
32 *char_dest = *char_src;
33 char_dest--;
34 char_src--;
35 count--;
36 }
37 }
38
39 return dest;
40}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

◆ mkstemps()

int mkstemps ( char template,
int  suffix_len 
)

Definition at line 73 of file mkstemps.c.

76{
77 static const char letters[]
78 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
79 static gcc_uint64_t value;
80#ifdef HAVE_GETTIMEOFDAY
81 struct timeval tv;
82#endif
83 char *XXXXXX;
84 size_t len;
85 int count;
86
87 len = strlen (template);
88
89 if ((int) len < 6 + suffix_len
90 || strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6))
91 {
92 printf("wrong parameter\n");
93 return -1;
94 }
95
96 XXXXXX = &template[len - 6 - suffix_len];
97
98#ifdef HAVE_GETTIMEOFDAY
99 /* Get some more or less random data. */
100 gettimeofday (&tv, NULL);
101 value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
102#else
103 value += getpid ();
104#endif
105
106 for (count = 0; count < TMP_MAX; ++count)
107 {
109 int fd;
110
111 /* Fill in the random bits. */
112 XXXXXX[0] = letters[v % 62];
113 v /= 62;
114 XXXXXX[1] = letters[v % 62];
115 v /= 62;
116 XXXXXX[2] = letters[v % 62];
117 v /= 62;
118 XXXXXX[3] = letters[v % 62];
119 v /= 62;
120 XXXXXX[4] = letters[v % 62];
121 v /= 62;
122 XXXXXX[5] = letters[v % 62];
123
124#ifdef VMS
125 fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600, "fop=tmd");
126#else
127 fd = open (template, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0600);
128#endif
129 if (fd >= 0)
130 /* The file does not exist. */
131 return fd;
132
133 /* This is a random value. It is only necessary that the next
134 TMP_MAX values generated by adding 7777 to VALUE are different
135 with (module 2^32). */
136 value += 7777;
137 }
138
139 /* We return the null string if we can't find a unique file name. */
140 template[0] = '\0';
141 return -1;
142}
#define O_CREAT
Definition: acwin.h:110
#define open
Definition: acwin.h:95
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
#define printf
Definition: freeldr.h:97
const GLdouble * v
Definition: gl.h:2040
GLenum GLsizei len
Definition: glext.h:6722
#define O_EXCL
Definition: fcntl.h:40
#define O_RDWR
Definition: fcntl.h:36
#define O_BINARY
Definition: mkstemps.c:48
unsigned long gcc_uint64_t
Definition: mkstemps.c:39
#define TMP_MAX
Definition: mkstemps.c:43
static int fd
Definition: io.c:51
Definition: pdh_main.c:94
#define getpid
Definition: wintirpc.h:52

◆ pread()

ssize_t pread ( int  fd,
void buf,
size_t  count,
off_t  offset 
)

◆ pwrite()

ssize_t pwrite ( int  fd,
const void buf,
size_t  count,
off_t  offset 
)

◆ spawnvp()

int spawnvp ( int  mode,
const char cmdname,
const char *const  argv[] 
)

◆ statfs()

int statfs ( const char name,
struct statfs *  info 
)

◆ strcasecmp()

int strcasecmp ( const char str1,
const char str2 
)

◆ strerror()

const char * strerror ( int  err)

Definition at line 23 of file compat_str.c.

24{
25 extern int sys_nerr;
26 extern char *sys_errlist[];
27
28 return (errnum < sys_nerr) ? sys_errlist[errnum] : "";
29}
#define sys_errlist
Definition: stdlib.h:1346
#define sys_nerr
Definition: stdlib.h:1347

◆ strncasecmp()

int strncasecmp ( const char str1,
const char str2,
size_t  n 
)

◆ usleep()

int usleep ( unsigned int  useconds)

Variable Documentation

◆ optarg

char* optarg
extern

Definition at line 49 of file getopt.c.

◆ opterr

int opterr
extern

Definition at line 46 of file getopt.c.

◆ optind

int optind
extern

Definition at line 47 of file getopt.c.

◆ optopt

int optopt
extern

Definition at line 48 of file getopt.c.