ReactOS  0.4.13-dev-100-gc8611ae
port.h File Reference
#include <fcntl.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <setjmp.h>
Include dependency graph for port.h:

Go to the source code of this file.

Classes

struct  statvfs
 
struct  option
 

Macros

#define _GNU_SOURCE   /* for pread/pwrite */
 
#define RTLD_LAZY   0x001
 
#define RTLD_NOW   0x002
 
#define RTLD_GLOBAL   0x100
 
#define S_ISLNK(mod)   (0)
 
#define S_ISSOCK(mod)   (0)
 
#define S_ISDIR(mod)   (((mod) & _S_IFMT) == _S_IFDIR)
 
#define S_ISCHR(mod)   (((mod) & _S_IFMT) == _S_IFCHR)
 
#define S_ISFIFO(mod)   (((mod) & _S_IFMT) == _S_IFIFO)
 
#define S_ISREG(mod)   (((mod) & _S_IFMT) == _S_IFREG)
 
#define S_IWUSR   0
 
#define O_LARGEFILE   0
 
#define O_NONBLOCK   0
 
#define O_BINARY   0
 
#define M_PI   3.14159265358979323846
 
#define M_PI_2   1.570796326794896619
 
#define __ASM_GLOBAL_FUNC(name, code)
 
#define _P_WAIT   0
 
#define _P_NOWAIT   1
 
#define _P_OVERLAY   2
 
#define _P_NOWAITO   3
 
#define _P_DETACH   4
 

Typedefs

typedef int mode_t
 
typedef long off_t
 
typedef int pid_t
 
typedef unsigned int size_t
 
typedef int ssize_t
 
typedef unsigned long fsblkcnt_t
 
typedef unsigned long fsfilcnt_t
 
typedef jmp_buf sigjmp_buf
 

Functions

int fstatvfs (int fd, struct statvfs *buf)
 
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)
 
int ffs (int x)
 
int futimes (int fd, const struct timeval tv[2])
 
size_t getpagesize (void)
 
pid_t gettid (void)
 
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 readlink (const char *path, char *buf, size_t size)
 
int sigsetjmp (sigjmp_buf buf, int savesigs)
 
void siglongjmp (sigjmp_buf buf, int val)
 
int statvfs (const char *path, struct statvfs *buf)
 
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[])
 
long interlocked_cmpxchg (long *dest, long xchg, long compare)
 
voidinterlocked_cmpxchg_ptr (void **dest, void *xchg, void *compare)
 
long interlocked_xchg (long *dest, long val)
 
voidinterlocked_xchg_ptr (void **dest, void *val)
 
long interlocked_xchg_add (long *dest, long incr)
 

Variables

charoptarg
 
int optind
 
int opterr
 
int optopt
 

Macro Definition Documentation

◆ __ASM_GLOBAL_FUNC

#define __ASM_GLOBAL_FUNC (   name,
  code 
)
Value:
void __asm_dummy_##name(void) { \
asm( ".align 4\n\t" \
".globl " __ASM_NAME(#name) "\n\t" \
__ASM_FUNC(#name) "\n" \
__ASM_NAME(#name) ":\n\t" \
code ); \
}
#define __ASM_NAME(name)
Definition: config.h:934
#define __ASM_FUNC(name)
Definition: config.h:931
Definition: name.c:36
GLuint const GLchar * name
Definition: glext.h:6031

Definition at line 201 of file port.h.

◆ _GNU_SOURCE

#define _GNU_SOURCE   /* for pread/pwrite */

Definition at line 28 of file port.h.

◆ _P_DETACH

#define _P_DETACH   4

Definition at line 374 of file port.h.

◆ _P_NOWAIT

#define _P_NOWAIT   1

Definition at line 371 of file port.h.

◆ _P_NOWAITO

#define _P_NOWAITO   3

Definition at line 373 of file port.h.

◆ _P_OVERLAY

#define _P_OVERLAY   2

Definition at line 372 of file port.h.

◆ _P_WAIT

#define _P_WAIT   0

Definition at line 370 of file port.h.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 181 of file port.h.

◆ M_PI_2

#define M_PI_2   1.570796326794896619

Definition at line 185 of file port.h.

◆ O_BINARY

#define O_BINARY   0

Definition at line 162 of file port.h.

◆ O_LARGEFILE

#define O_LARGEFILE   0

Definition at line 154 of file port.h.

◆ O_NONBLOCK

#define O_NONBLOCK   0

Definition at line 158 of file port.h.

◆ RTLD_GLOBAL

#define RTLD_GLOBAL   0x100

Definition at line 101 of file port.h.

◆ RTLD_LAZY

#define RTLD_LAZY   0x001

Definition at line 99 of file port.h.

◆ RTLD_NOW

#define RTLD_NOW   0x002

Definition at line 100 of file port.h.

◆ S_ISCHR

#define S_ISCHR (   mod)    (((mod) & _S_IFMT) == _S_IFCHR)

Definition at line 137 of file port.h.

◆ S_ISDIR

#define S_ISDIR (   mod)    (((mod) & _S_IFMT) == _S_IFDIR)

Definition at line 133 of file port.h.

◆ S_ISFIFO

#define S_ISFIFO (   mod)    (((mod) & _S_IFMT) == _S_IFIFO)

Definition at line 141 of file port.h.

◆ S_ISLNK

#define S_ISLNK (   mod)    (0)

Definition at line 125 of file port.h.

◆ S_ISREG

#define S_ISREG (   mod)    (((mod) & _S_IFMT) == _S_IFREG)

Definition at line 145 of file port.h.

◆ S_ISSOCK

#define S_ISSOCK (   mod)    (0)

Definition at line 129 of file port.h.

◆ S_IWUSR

#define S_IWUSR   0

Definition at line 149 of file port.h.

Typedef Documentation

◆ fsblkcnt_t

typedef unsigned long fsblkcnt_t

Definition at line 68 of file port.h.

◆ fsfilcnt_t

typedef unsigned long fsfilcnt_t

Definition at line 71 of file port.h.

◆ mode_t

typedef int mode_t

Definition at line 53 of file port.h.

◆ off_t

typedef long off_t

Definition at line 56 of file port.h.

◆ pid_t

typedef int pid_t

Definition at line 59 of file port.h.

◆ sigjmp_buf

Definition at line 324 of file port.h.

◆ size_t

typedef unsigned int size_t

Definition at line 62 of file port.h.

◆ ssize_t

typedef int ssize_t

Definition at line 65 of file port.h.

Function Documentation

◆ ffs()

◆ fstatvfs()

int fstatvfs ( int  fd,
struct statvfs buf 
)

◆ futimes()

int futimes ( int  fd,
const struct timeval  tv[2] 
)

◆ 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
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 _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
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:36
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 
)

Definition at line 505 of file reactos_support_code.c.

507 {
508 
509  return (getopt_internal(nargc, nargv, options, long_options, idx,
511 }
static const struct option long_options[]
Definition: widl.c:185
#define FLAG_LONGONLY
unsigned int idx
Definition: utils.c:41
#define FLAG_PERMUTE
static int getopt_internal(int nargc, char *const *nargv, const char *options, const struct option *long_options, int *idx, int flags)

◆ getpagesize()

size_t getpagesize ( void  )

◆ gettid()

pid_t gettid ( void  )

◆ interlocked_cmpxchg()

long interlocked_cmpxchg ( long dest,
long  xchg,
long  compare 
)

◆ interlocked_cmpxchg_ptr()

void* interlocked_cmpxchg_ptr ( void **  dest,
void xchg,
void compare 
)

◆ interlocked_xchg()

long interlocked_xchg ( long dest,
long  val 
)

◆ interlocked_xchg_add()

long interlocked_xchg_add ( long dest,
long  incr 
)

Referenced by get_temp_buffer().

◆ interlocked_xchg_ptr()

void* interlocked_xchg_ptr ( void **  dest,
void val 
)

◆ 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 76 of file mkstemps.c.

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

Referenced by chmc_section_create(), do_import(), main(), and switch_to_acf().

◆ pread()

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

Referenced by fread(), and teststream_Read().

◆ pwrite()

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

◆ readlink()

int readlink ( const char path,
char buf,
size_t  size 
)

◆ siglongjmp()

void siglongjmp ( sigjmp_buf  buf,
int  val 
)

◆ sigsetjmp()

◆ spawnvp()

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

◆ statvfs()

int statvfs ( const char path,
struct statvfs buf 
)

◆ strcasecmp()

int strcasecmp ( const char str1,
const char str2 
)

◆ strerror()

◆ strncasecmp()

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

◆ usleep()

int usleep ( unsigned int  useconds)

Referenced by wave_out_play().

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.