ssp-internal.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Distributed under the terms of the GNU Lesser General Public License
  3. * $Header: $
  4. */
  5. #ifndef _SSP_INTERNAL_H
  6. #define _SSP_INTERNAL_H 1
  7. #ifdef __SSP__
  8. #error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector"
  9. #endif
  10. #ifdef __PROPOLICE_BLOCK_SEGV__
  11. # define SSP_SIGTYPE SIGSEGV
  12. #else
  13. # define SSP_SIGTYPE SIGABRT
  14. #endif
  15. #include <sys/types.h>
  16. #include <sys/time.h>
  17. #include <signal.h>
  18. #include <linux/unistd.h>
  19. #ifndef __SSP_QUICK_CANARY__
  20. #define __NR___kernel_open __NR_open
  21. static __always_inline _syscall3(int,__kernel_open,const char *,path,int,flags,__kernel_mode_t,mode);
  22. #define OPEN(path, flags, mode) __kernel_open(path, flags, mode)
  23. /* void * = __ptr_t */
  24. #define __NR___kernel_read __NR_read
  25. static __always_inline _syscall3(ssize_t,__kernel_read,int,fd,void *,buf,size_t,count);
  26. #define READ(fd, buf, count) __kernel_read(fd, buf, count)
  27. #define __NR___kernel_close __NR_close
  28. static __always_inline _syscall1(int,__kernel_close,int,fd);
  29. #define CLOSE(fd) __kernel_close(fd)
  30. #endif
  31. /* const void * = const __ptr_t */
  32. #define __NR___kernel_write __NR_write
  33. static __always_inline _syscall3(ssize_t,__kernel_write,int,fd,const void *,buf,size_t,count);
  34. #define WRITE(fd, buf, count) __kernel_write(fd, buf, count)
  35. /* not using __NR_ */
  36. #define __NR___kernel_gettimeofday __NR_gettimeofday
  37. static __always_inline _syscall2(int,__kernel_gettimeofday,struct timeval *,tv,struct timezone *,tz);
  38. #define GETTIMEOFDAY(tv, tz) __kernel_gettimeofday(tv, tz)
  39. #define __NR___kernel_getpid __NR_getpid
  40. static __always_inline _syscall0(pid_t,__kernel_getpid);
  41. #define GETPID() __kernel_getpid()
  42. //#ifdef __NR_rt_sigaction
  43. //#define __NR___kernel_sigaction __NR_rt_sigaction
  44. //static __always_inline _syscall4(...);
  45. //#else
  46. #define __NR___kernel_sigaction __NR_sigaction
  47. static __always_inline _syscall3(int,__kernel_sigaction,int,signum,const struct sigaction *,act,struct sigaction *,oldact);
  48. //#endif
  49. #define SIGACTION(signum, act, oldact) __kernel_sigaction(signum, act, oldact)
  50. //#ifdef __NR_rt_sigprocmask
  51. //#define __NR___kernel_sigprocmask __NR_rt_sigprocmask
  52. //static __always_inline _syscall4(...);
  53. //#else
  54. #define __NR___kernel_sigprocmask __NR_sigprocmask
  55. static __always_inline _syscall3(int,__kernel_sigprocmask,int,how,const sigset_t *,set,sigset_t *,oldset);
  56. //#endif
  57. #define SIGPROCMASK(how, set, oldset) __kernel_sigprocmask(how, set, oldset)
  58. #define __NR___kernel_kill __NR_kill
  59. static __always_inline _syscall2(int,__kernel_kill,__kernel_pid_t,pid,int,sig);
  60. #define KILL(pid, sig) __kernel_kill(pid, sig)
  61. #define __NR___kernel_exit __NR_exit
  62. static __always_inline _syscall1(void,__kernel_exit,int,status);
  63. #define EXIT(status) __kernel_exit(status)
  64. #endif /* _SSP_INTERNAL_H */