1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _SYS_LX_TYPES_H
  27 #define _SYS_LX_TYPES_H
  28 
  29 #pragma ident   "%Z%%M% %I%     %E% SMI"
  30 
  31 #ifdef  __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #define SHRT_MIN        (-32768)        /* min value of a "short int" */
  36 #define SHRT_MAX        32767           /* max value of a "short int" */
  37 #define USHRT_MAX       65535           /* max of "unsigned short int" */
  38 #define INT_MIN         (-2147483647-1) /* min value of an "int" */
  39 #define INT_MAX         2147483647      /* max value of an "int" */
  40 #define UINT_MAX        4294967295U     /* max value of an "unsigned int" */
  41 #define LONG_MIN        (-2147483647L-1L)
  42                                         /* min value of a "long int" */
  43 #define LONG_MAX        2147483647L     /* max value of a "long int" */
  44 #define ULONG_MAX       4294967295UL    /* max of "unsigned long int" */
  45 
  46 #define LX_SYS_UTS_LN   65
  47 
  48 struct lx_utsname {
  49         char    sysname[LX_SYS_UTS_LN];
  50         char    nodename[LX_SYS_UTS_LN];
  51         char    release[LX_SYS_UTS_LN];
  52         char    version[LX_SYS_UTS_LN];
  53         char    machine[LX_SYS_UTS_LN];
  54         char    domainname[LX_SYS_UTS_LN];
  55 };
  56 
  57 typedef uint64_t        lx_dev_t;
  58 typedef uint16_t        lx_dev16_t;
  59 typedef uint32_t        lx_ino_t;
  60 typedef uint64_t        lx_ino64_t;
  61 typedef uint32_t        lx_uid_t;
  62 typedef uint16_t        lx_uid16_t;
  63 typedef uint32_t        lx_gid_t;
  64 typedef uint16_t        lx_gid16_t;
  65 typedef uint32_t        lx_off_t;
  66 typedef uint64_t        lx_off64_t;
  67 typedef uint32_t        lx_blksize_t;
  68 typedef uint32_t        lx_blkcnt_t;
  69 typedef uint64_t        lx_blkcnt64_t;
  70 typedef ulong_t         lx_mode_t;
  71 typedef uint16_t        lx_mode16_t;
  72 
  73 #define LX_UID16_TO_UID32(uid16)        \
  74         (((uid16) == (lx_uid16_t)-1) ? ((lx_uid_t)-1) : (lx_uid_t)(uid16))
  75 
  76 #define LX_GID16_TO_GID32(gid16)     \
  77         (((gid16) == (lx_gid16_t)-1) ? ((lx_gid_t)-1) : (lx_gid_t)(gid16))
  78 
  79 /* Overflow values default to NFS nobody. */
  80 
  81 #define UID16_OVERFLOW  ((lx_uid16_t)65534)
  82 #define GID16_OVERFLOW  ((lx_gid16_t)65534)
  83 
  84 /*
  85  * All IDs with high word non-zero are converted to default overflow values to
  86  * avoid inadvertent truncation to zero (root) (!).
  87  */
  88 #define LX_UID32_TO_UID16(uid32)        \
  89         ((((uid32) & 0xffff0000) == 0)  ? ((lx_uid16_t)(uid32)) : \
  90             (((uid32) == ((lx_uid_t)-1)) ? ((lx_uid16_t)-1) : UID16_OVERFLOW))
  91 
  92 #define LX_GID32_TO_GID16(gid32)        \
  93         ((((gid32) & 0xffff0000) == 0)  ? ((lx_gid16_t)(gid32)) : \
  94             (((gid32) == ((lx_gid_t)-1)) ? ((lx_gid16_t)-1) : GID16_OVERFLOW))
  95 
  96 struct lx_timespec {
  97         time_t  ts_sec;
  98         long    ts_nsec;
  99 };
 100 
 101 #define LX_32TO64(lo, hi)       \
 102         ((uint64_t)((uint64_t)(lo) | ((uint64_t)(hi) << 32)))
 103 
 104 #ifdef  __cplusplus
 105 }
 106 #endif
 107 
 108 #endif  /* _SYS_LX_TYPES_H */