root/include/asm-alpha/segment.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. __put_user
  2. __get_user
  3. get_user_byte
  4. get_user_word
  5. get_user_long
  6. get_user_quad
  7. put_user_byte
  8. put_user_word
  9. put_user_long
  10. put_user_quad
  11. get_fs
  12. get_ds
  13. set_fs

   1 #ifndef _ASM_SEGMENT_H
   2 #define _ASM_SEGMENT_H
   3 
   4 #include <linux/string.h>
   5 
   6 /*
   7  * Uh, these should become the main single-value transfer routines..
   8  * They automatically use the right size if we just have the right
   9  * pointer type..
  10  */
  11 #define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
  12 #define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
  13 
  14 /*
  15  * This is a silly but good way to make sure that
  16  * the __put_user function is indeed always optimized,
  17  * and that we use the correct sizes..
  18  */
  19 extern int bad_user_access_length(void);
  20 
  21 /* I should make this use unaligned transfers etc.. */
  22 static inline void __put_user(unsigned long x, void * y, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
  23 {
  24         switch (size) {
  25                 case 1:
  26                         *(char *) y = x;
  27                         break;
  28                 case 2:
  29                         *(short *) y = x;
  30                         break;
  31                 case 4:
  32                         *(int *) y = x;
  33                         break;
  34                 case 8:
  35                         *(long *) y = x;
  36                         break;
  37                 default:
  38                         bad_user_access_length();
  39         }
  40 }
  41 
  42 /* I should make this use unaligned transfers etc.. */
  43 static inline unsigned long __get_user(const void * y, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
  44 {
  45         switch (size) {
  46                 case 1:
  47                         return *(unsigned char *) y;
  48                 case 2:
  49                         return *(unsigned short *) y;
  50                 case 4:
  51                         return *(unsigned int *) y;
  52                 case 8:
  53                         return *(unsigned long *) y;
  54                 default:
  55                         return bad_user_access_length();
  56         }
  57 }
  58 
  59 static inline unsigned char get_user_byte(const char * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61         return *addr;
  62 }
  63 
  64 #define get_fs_byte(addr) get_user_byte((char *)(addr))
  65 
  66 static inline unsigned short get_user_word(const short *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  67 {
  68         return *addr;
  69 }
  70 
  71 #define get_fs_word(addr) get_user_word((short *)(addr))
  72 
  73 static inline unsigned long get_user_long(const int *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  74 {
  75         return *addr;
  76 }
  77 
  78 #define get_fs_long(addr) get_user_long((int *)(addr))
  79 
  80 static inline unsigned long get_user_quad(const long *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  81 {
  82         return *addr;
  83 }
  84 
  85 #define get_fs_quad(addr) get_user_quad((long *)(addr))
  86 
  87 static inline void put_user_byte(char val,char *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  88 {
  89         *addr = val;
  90 }
  91 
  92 #define put_fs_byte(x,addr) put_user_byte((x),(char *)(addr))
  93 
  94 static inline void put_user_word(short val,short * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  95 {
  96         *addr = val;
  97 }
  98 
  99 #define put_fs_word(x,addr) put_user_word((x),(short *)(addr))
 100 
 101 static inline void put_user_long(unsigned long val,int * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 102 {
 103         *addr = val;
 104 }
 105 
 106 #define put_fs_long(x,addr) put_user_long((x),(int *)(addr))
 107 
 108 static inline void put_user_quad(unsigned long val,long * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 109 {
 110         *addr = val;
 111 }
 112 
 113 #define put_fs_quad(x,addr) put_user_quad((x),(long *)(addr))
 114 
 115 #define memcpy_fromfs(to, from, n) memcpy((to),(from),(n))
 116 
 117 #define memcpy_tofs(to, from, n) memcpy((to),(from),(n))
 118 
 119 /*
 120  * For segmented architectures, these are used to specify which segment
 121  * to use for the above functions.
 122  *
 123  * The alpha is not segmented, so these are just dummies.
 124  */
 125 
 126 #define KERNEL_DS 0
 127 #define USER_DS 1
 128 
 129 static inline unsigned long get_fs(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 130 {
 131         return 1;
 132 }
 133 
 134 static inline unsigned long get_ds(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 135 {
 136         return 0;
 137 }
 138 
 139 static inline void set_fs(unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
 140 {
 141 }
 142 
 143 #endif /* _ASM_SEGMENT_H */

/* [previous][next][first][last][top][bottom][index][help] */