root/include/asm-sparc/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. put_user_byte
  7. put_user_word
  8. put_user_long
  9. get_fs
  10. get_ds
  11. set_fs

   1 /* $Id: segment.h,v 1.6 1995/11/25 02:32:40 davem Exp $ */
   2 #ifndef _ASM_SEGMENT_H
   3 #define _ASM_SEGMENT_H
   4 
   5 /* Sparc is not segmented, these are just place holders. */
   6 #define KERNEL_DS   0
   7 #define USER_DS     1
   8 
   9 #include <linux/string.h>
  10 #include <asm/vac-ops.h>
  11 
  12 #ifndef __ASSEMBLY__
  13 
  14 /*
  15  * Uh, these should become the main single-value transfer routines..
  16  * They automatically use the right size if we just have the right
  17  * pointer type..
  18  */
  19 #define put_user(x,ptr) __put_user((unsigned long)(x),(ptr),sizeof(*(ptr)))
  20 #define get_user(ptr) ((__typeof__(*(ptr)))__get_user((ptr),sizeof(*(ptr))))
  21 
  22 /*
  23  * This is a silly but good way to make sure that
  24  * the __put_user function is indeed always optimized,
  25  * and that we use the correct sizes..
  26  */
  27 extern int bad_user_access_length(void);
  28 
  29 /* I should make this use unaligned transfers etc.. */
  30 static inline void __put_user(unsigned long x, void * y, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32         switch (size) {
  33                 case 1:
  34                         *(char *) y = x;
  35                         break;
  36                 case 2:
  37                         *(short *) y = x;
  38                         break;
  39                 case 4:
  40                         *(int *) y = x;
  41                         break;
  42                 default:
  43                         bad_user_access_length();
  44         }
  45 }
  46 
  47 /* I should make this use unaligned transfers etc.. */
  48 static inline unsigned long __get_user(const void * y, int size)
     /* [previous][next][first][last][top][bottom][index][help] */
  49 {
  50         switch (size) {
  51                 case 1:
  52                         return *(unsigned char *) y;
  53                 case 2:
  54                         return *(unsigned short *) y;
  55                 case 4:
  56                         return *(unsigned int *) y;
  57                 default:
  58                         return bad_user_access_length();
  59         }
  60 }
  61 
  62 /*
  63  * Deprecated routines
  64  */
  65 
  66 static inline unsigned char get_user_byte(const char * addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  67 {
  68         return *addr;
  69 }
  70 
  71 #define get_fs_byte(addr) get_user_byte((char *)(addr))
  72 
  73 static inline unsigned short get_user_word(const short *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  74 {
  75         return *addr;
  76 }
  77 
  78 #define get_fs_word(addr) get_user_word((short *)(addr))
  79 
  80 static inline unsigned long get_user_long(const int *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
  81 {
  82         return *addr;
  83 }
  84 
  85 #define get_fs_long(addr) get_user_long((int *)(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 #define memcpy_fromfs(to, from, n) memcpy((to),(from),(n))
 109 
 110 #define memcpy_tofs(to, from, n) memcpy((to),(from),(n))
 111 
 112 extern int current_user_segment;
 113 
 114 static inline unsigned long get_fs(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 115 {
 116         return current_user_segment;
 117 }
 118 
 119 static inline unsigned long get_ds(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 120 {
 121         return KERNEL_DS;
 122 }
 123 
 124 static inline void set_fs(unsigned long val)
     /* [previous][next][first][last][top][bottom][index][help] */
 125 {
 126         current_user_segment = val;
 127 }
 128 
 129 #endif  /* __ASSEMBLY__ */
 130 
 131 #endif /* _ASM_SEGMENT_H */

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