Advertisement
Guest User

Untitled

a guest
May 28th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.07 KB | None | 0 0
  1. /*
  2.  *  This file is part of libth.
  3.  *
  4.  *  libth is free software: you can redistribute it and/or modify
  5.  *  it under the terms of the GNU General Public License as published by
  6.  *  the Free Software Foundation, either version 3 of the License, or
  7.  *  (at your option) any later version.
  8.  *
  9.  *  libth is distributed in the hope that it will be useful,
  10.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  *  GNU General Public License for more details.
  13.  *
  14.  *  You should have received a copy of the GNU General Public License
  15.  *  along with libth.  If not, see <http://www.gnu.org/licenses/>.
  16.  */
  17. #ifndef _TH_H
  18. #define _TH_H
  19. /*
  20.  * Standard Header - to be included before all standard system headers.
  21.  *
  22.  * Attribution: UNIX Network Programming Volume 1
  23.  *  - W. Richard Stevens, Bill Fenner, Andrew M. Rudoff
  24.  */
  25. #define _POSIX_C_SOURCE 200809L
  26.  
  27. #include <stdio.h>                              /* for convenience */
  28. #include <stdlib.h>                             /* for convenience */
  29. #include <string.h>                             /* for convenience */
  30. #include <unistd.h>                             /* for convenience */
  31. #include <sys/types.h>          /* basic system data types */
  32.  
  33. #define max(a,b) \
  34.    ({ __typeof__ (a) _a = (a); \
  35.        __typeof__ (b) _b = (b); \
  36.      _a > _b ? _a : _b; })
  37.  
  38. #define min(a,b) \
  39.    ({ __typeof__ (a) _a = (a); \
  40.        __typeof__ (b) _b = (b); \
  41.      _a < _b ? _a : _b; })
  42.  
  43. /* Define bzero() as macro */
  44. #define bzero(ptr, n) memset(ptr, 0, (size_t)(n))
  45.  
  46. ssize_t Readn(int fd, void *ptr, size_t nbytes); /* readn.c */
  47. void Writen(int fd, void *ptr, size_t nbytes);   /* writen.c */
  48.  
  49. /* error funtion prototypes: error.c */
  50. void    err_ret(const char *fmt, ...);
  51. void    err_sys(const char *fmt, ...) __attribute__((noreturn));
  52. void    err_dump(const char *fmt, ...) __attribute__((noreturn));
  53. void    err_msg(const char *fmt, ...);
  54. void    err_quit(const char *fmt, ...) __attribute__((noreturn));
  55.  
  56. /* prototypes for our Unix wrapper functions: wrapunix.c */
  57. void    *Calloc(size_t, size_t);
  58. void     Close(int);
  59. void     Dup2(int, int);
  60. int              Fcntl(int, int, int);
  61. int              Ioctl(int, int, void *);
  62. pid_t    Fork(void);
  63. /* void Gettimeofday(struct timeval *tv, void *foo); */
  64. void    *Malloc(size_t);
  65. int          Mkstemp(char *);
  66. void    *Mmap(void *, size_t, int, int, int, off_t);
  67. int              Open(const char *, int, mode_t);
  68. void     Pipe(int *fds);
  69. ssize_t  Read(int, void *, size_t);
  70. char    *Strdup(const char *);
  71. long     Sysconf(int);
  72. /* void  Sysctl(int *, uint32_t, void *, size_t *, void *, size_t); */
  73. void     Unlink(const char *);
  74. pid_t    Wait(int *);
  75. pid_t    Waitpid(pid_t, int *, int);
  76. void     Write(int, void *, size_t);
  77.  
  78. /* prototypes for our stdio wrapper functions: wrapstdio.c */
  79. void     Fclose(FILE *);
  80. FILE    *Fdopen(int, const char *);
  81. char    *Fgets(char *, int, FILE *);
  82. FILE    *Fopen(const char *, const char *);
  83. void     Fputs(const char *, FILE *);
  84.  
  85. #endif  /* _TH_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement