ReactOS  0.4.14-dev-614-gbfd8a84
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:

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 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 364 of file port.h.

◆ INFINITY

#define INFINITY   __port_infinity()

Definition at line 162 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  }
313  nonopt_start = nonopt_end = -1;
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)
351  optopt = long_options[match].val;
352  else
353  optopt = 0;
354  return BADARG;
355  }
356  if (long_options[match].has_arg == required_argument ||
357  long_options[match].has_arg == optional_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)
373  optopt = long_options[match].val;
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 }
static char EMSG[1]
Definition: getopt.c:49
int optopt
Definition: getopt.c:47
#define BADARG
Definition: getopt.c:46
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
Definition: match.c:28
int optind
Definition: getopt.c:47
static const char noarg[]
Definition: getopt.c:63
#define BADCH
Definition: getopt.c:45
static void permute_args(int, int, int, char *const *)
Definition: getopt.c:103
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
static const struct option long_options[]
Definition: widl.c:185
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
static void warnx(const char *fmt,...)
Definition: getopt.c:77
struct match match
Definition: match.c:33
#define required_argument
Definition: getopt.h:123
static char * place
Definition: getopt.c:55
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static int getopt_internal(int, char *const *, const char *)
Definition: getopt.c:137
#define optional_argument
Definition: getopt.h:124
#define _DIAGASSERT(x)
Definition: getopt.c:11
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
#define no_argument
Definition: getopt.h:122
static int nonopt_start
Definition: getopt.c:57
const char * optarg
Definition: getopt.c:49
#define PRINT_ERROR
Definition: getopt.c:35
char * strchr(const char *String, int ch)
Definition: utclib.c:501
Definition: name.c:38
static const char ambig[]
Definition: getopt.c:62
static int nonopt_end
Definition: getopt.c:58
static const char illoptstring[]
Definition: getopt.c:65
static const char recargstring[]
Definition: getopt.c:61

◆ 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)

Referenced by wined3d_ftoa().

◆ isinf()

◆ isnan()

◆ 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 4 of file memmove.c.

5 {
6  char *char_dest = (char *)dest;
7  char *char_src = (char *)src;
8 
9  if ((char_dest <= char_src) || (char_dest >= (char_src+count)))
10  {
11  /* non-overlapping buffers */
12  while(count > 0)
13  {
14  *char_dest = *char_src;
15  char_dest++;
16  char_src++;
17  count--;
18  }
19  }
20  else
21  {
22  /* overlaping buffers */
23  char_dest = (char *)dest + count - 1;
24  char_src = (char *)src + count - 1;
25 
26  while(count > 0)
27  {
28  *char_dest = *char_src;
29  char_dest--;
30  char_src--;
31  count--;
32  }
33  }
34 
35  return dest;
36 }
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  {
108  gcc_uint64_t v = value;
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 TMP_MAX
Definition: mkstemps.c:43
#define open
Definition: acwin.h:95
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLuint GLuint GLsizei count
Definition: gl.h:1545
static int fd
Definition: io.c:51
#define gettimeofday(tv, tz)
Definition: adns_win32.h:159
smooth NULL
Definition: ftsmooth.c:416
#define O_EXCL
Definition: fcntl.h:40
_CRTIMP int __cdecl getpid(void)
unsigned long gcc_uint64_t
Definition: mkstemps.c:39
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
GLenum GLsizei len
Definition: glext.h:6722
GLsizei const GLfloat * value
Definition: glext.h:6069
const GLdouble * v
Definition: gl.h:2040
#define O_RDWR
Definition: fcntl.h:36
#define O_BINARY
Definition: mkstemps.c:48
#define O_CREAT
Definition: acwin.h:110
#define printf
Definition: config.h:203

◆ 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 }
int sys_nerr
char * sys_errlist[]

◆ strncasecmp()

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

◆ usleep()

int usleep ( unsigned int  useconds)

Variable Documentation

◆ optarg

char* optarg

Definition at line 49 of file getopt.c.

◆ opterr

int opterr

Definition at line 46 of file getopt.c.

◆ optind

int optind

Definition at line 47 of file getopt.c.

◆ optopt

int optopt

Definition at line 47 of file getopt.c.