OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [mw/] [src/] [engine/] [devopen.i] - Rev 1765

Compare with Previous | Blame | View Log

# 1 "devopen.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "devopen.c"
# 15 "devopen.c"
# 1 "/projects/or32-uclinux/include/stdio.h" 1
# 28 "/projects/or32-uclinux/include/stdio.h"
# 1 "/projects/or32-uclinux/include/features.h" 1
# 292 "/projects/or32-uclinux/include/features.h"
# 1 "/projects/or32-uclinux/include/sys/cdefs.h" 1
# 293 "/projects/or32-uclinux/include/features.h" 2
# 327 "/projects/or32-uclinux/include/features.h"
# 1 "/projects/or32-uclinux/include/bits/uClibc_config.h" 1
# 328 "/projects/or32-uclinux/include/features.h" 2
# 29 "/projects/or32-uclinux/include/stdio.h" 2





# 1 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stddef.h" 1
# 201 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stddef.h"
typedef unsigned int size_t;
# 35 "/projects/or32-uclinux/include/stdio.h" 2

# 1 "/projects/or32-uclinux/include/bits/types.h" 1
# 29 "/projects/or32-uclinux/include/bits/types.h"
# 1 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stddef.h" 1
# 30 "/projects/or32-uclinux/include/bits/types.h" 2


typedef unsigned char __u_char;
typedef unsigned short __u_short;
typedef unsigned int __u_int;
typedef unsigned long __u_long;

__extension__ typedef unsigned long long int __u_quad_t;
__extension__ typedef long long int __quad_t;
# 49 "/projects/or32-uclinux/include/bits/types.h"
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;

__extension__ typedef signed long long int __int64_t;
__extension__ typedef unsigned long long int __uint64_t;

typedef __quad_t *__qaddr_t;



typedef __u_int __dev_t;
typedef __u_int __uid_t;
typedef __u_int __gid_t;
typedef __u_int __ino_t;
typedef __u_int __mode_t;
typedef __u_short __nlink_t;
typedef long int __off_t;
typedef __quad_t __loff_t;
typedef int __pid_t;
typedef int __ssize_t;
typedef __u_long __rlim_t;
typedef __u_quad_t __rlim64_t;
typedef __u_int __id_t;

typedef struct
  {
    int __val[2];
  } __fsid_t;


typedef int __daddr_t;
typedef char *__caddr_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;
typedef long int __swblk_t;

typedef long int __clock_t;


typedef int __clockid_t;


typedef int __timer_t;






typedef int __key_t;


typedef unsigned short int __ipc_pid_t;



typedef long int __blksize_t;




typedef long int __blkcnt_t;
typedef __quad_t __blkcnt64_t;


typedef __u_long __fsblkcnt_t;
typedef __u_quad_t __fsblkcnt64_t;


typedef __u_long __fsfilcnt_t;
typedef __u_quad_t __fsfilcnt64_t;


typedef __u_quad_t __ino64_t;


typedef __loff_t __off64_t;


typedef long int __t_scalar_t;
typedef unsigned long int __t_uscalar_t;


typedef int __intptr_t;


typedef unsigned int __socklen_t;




# 1 "/projects/or32-uclinux/include/bits/pthreadtypes.h" 1
# 23 "/projects/or32-uclinux/include/bits/pthreadtypes.h"
# 1 "/projects/or32-uclinux/include/bits/sched.h" 1
# 68 "/projects/or32-uclinux/include/bits/sched.h"
struct __sched_param
  {
    int __sched_priority;
  };
# 24 "/projects/or32-uclinux/include/bits/pthreadtypes.h" 2


struct _pthread_fastlock
{
  long int __status;
  int __spinlock;

};



typedef struct _pthread_descr_struct *_pthread_descr;





typedef struct __pthread_attr_s
{
  int __detachstate;
  int __schedpolicy;
  struct __sched_param __schedparam;
  int __inheritsched;
  int __scope;
  size_t __guardsize;
  int __stackaddr_set;
  void *__stackaddr;
  size_t __stacksize;
} pthread_attr_t;



typedef struct
{
  struct _pthread_fastlock __c_lock;
  _pthread_descr __c_waiting;
} pthread_cond_t;



typedef struct
{
  int __dummy;
} pthread_condattr_t;


typedef unsigned int pthread_key_t;





typedef struct
{
  int __m_reserved;
  int __m_count;
  _pthread_descr __m_owner;
  int __m_kind;
  struct _pthread_fastlock __m_lock;
} pthread_mutex_t;



typedef struct
{
  int __mutexkind;
} pthread_mutexattr_t;



typedef int pthread_once_t;
# 140 "/projects/or32-uclinux/include/bits/pthreadtypes.h"
typedef unsigned long int pthread_t;
# 146 "/projects/or32-uclinux/include/bits/types.h" 2
# 37 "/projects/or32-uclinux/include/stdio.h" 2



# 1 "/projects/or32-uclinux/include/sys/types.h" 1
# 28 "/projects/or32-uclinux/include/sys/types.h"






typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;




typedef __loff_t loff_t;



typedef __ino_t ino_t;
# 61 "/projects/or32-uclinux/include/sys/types.h"
typedef __dev_t dev_t;




typedef __gid_t gid_t;




typedef __mode_t mode_t;




typedef __nlink_t nlink_t;




typedef __uid_t uid_t;





typedef __off_t off_t;
# 99 "/projects/or32-uclinux/include/sys/types.h"
typedef __pid_t pid_t;




typedef __id_t id_t;




typedef __ssize_t ssize_t;





typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;





typedef __key_t key_t;
# 132 "/projects/or32-uclinux/include/sys/types.h"
# 1 "/projects/or32-uclinux/include/time.h" 1
# 70 "/projects/or32-uclinux/include/time.h"
typedef __time_t time_t;
# 82 "/projects/or32-uclinux/include/time.h"
typedef __clockid_t clockid_t;
# 94 "/projects/or32-uclinux/include/time.h"
typedef __timer_t timer_t;
# 133 "/projects/or32-uclinux/include/sys/types.h" 2
# 146 "/projects/or32-uclinux/include/sys/types.h"
# 1 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stddef.h" 1
# 147 "/projects/or32-uclinux/include/sys/types.h" 2



typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
# 190 "/projects/or32-uclinux/include/sys/types.h"
typedef int int8_t __attribute__ ((__mode__ (__QI__)));
typedef int int16_t __attribute__ ((__mode__ (__HI__)));
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef int int64_t __attribute__ ((__mode__ (__DI__)));


typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));

typedef int register_t __attribute__ ((__mode__ (__word__)));
# 212 "/projects/or32-uclinux/include/sys/types.h"
# 1 "/projects/or32-uclinux/include/endian.h" 1
# 37 "/projects/or32-uclinux/include/endian.h"
# 1 "/projects/or32-uclinux/include/bits/endian.h" 1
# 38 "/projects/or32-uclinux/include/endian.h" 2
# 213 "/projects/or32-uclinux/include/sys/types.h" 2


# 1 "/projects/or32-uclinux/include/sys/select.h" 1
# 31 "/projects/or32-uclinux/include/sys/select.h"
# 1 "/projects/or32-uclinux/include/bits/select.h" 1
# 32 "/projects/or32-uclinux/include/sys/select.h" 2


# 1 "/projects/or32-uclinux/include/bits/sigset.h" 1
# 23 "/projects/or32-uclinux/include/bits/sigset.h"
typedef int __sig_atomic_t;




typedef struct
  {
    unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
  } __sigset_t;
# 35 "/projects/or32-uclinux/include/sys/select.h" 2



typedef __sigset_t sigset_t;




# 1 "/projects/or32-uclinux/include/time.h" 1
# 106 "/projects/or32-uclinux/include/time.h"
struct timespec
  {
    long int tv_sec;
    long int tv_nsec;
  };
# 44 "/projects/or32-uclinux/include/sys/select.h" 2

# 1 "/projects/or32-uclinux/include/bits/time.h" 1
# 63 "/projects/or32-uclinux/include/bits/time.h"
struct timeval
  {
    __time_t tv_sec;
    __suseconds_t tv_usec;
  };
# 46 "/projects/or32-uclinux/include/sys/select.h" 2



typedef long int __fd_mask;







typedef struct
  {






    __fd_mask __fds_bits[1024 / (8 * sizeof (__fd_mask))];


  } fd_set;






typedef __fd_mask fd_mask;
# 89 "/projects/or32-uclinux/include/sys/select.h"







extern int select (int __nfds, fd_set *__restrict __readfds,
                   fd_set *__restrict __writefds,
                   fd_set *__restrict __exceptfds,
                   struct timeval *__restrict __timeout) ;
# 112 "/projects/or32-uclinux/include/sys/select.h"

# 216 "/projects/or32-uclinux/include/sys/types.h" 2


# 1 "/projects/or32-uclinux/include/sys/sysmacros.h" 1
# 219 "/projects/or32-uclinux/include/sys/types.h" 2
# 230 "/projects/or32-uclinux/include/sys/types.h"
typedef __blkcnt_t blkcnt_t;



typedef __fsblkcnt_t fsblkcnt_t;



typedef __fsfilcnt_t fsfilcnt_t;
# 262 "/projects/or32-uclinux/include/sys/types.h"

# 41 "/projects/or32-uclinux/include/stdio.h" 2
# 50 "/projects/or32-uclinux/include/stdio.h"
struct _UC_FILE {
  unsigned char *bufpos;
  unsigned char *bufread;
  unsigned char *bufwrite;
  unsigned char *bufstart;
  unsigned char *bufend;

  struct _UC_FILE * next;

  int fd;

  unsigned char mode;
  unsigned char ungot;
  char unbuf[2];
};

typedef struct _UC_FILE FILE;
# 76 "/projects/or32-uclinux/include/stdio.h"
typedef struct _UC_FILE __FILE;
# 88 "/projects/or32-uclinux/include/stdio.h"
# 1 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stdarg.h" 1
# 43 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stdarg.h"
typedef __builtin_va_list __gnuc_va_list;
# 89 "/projects/or32-uclinux/include/stdio.h" 2




typedef __off_t fpos_t;
# 151 "/projects/or32-uclinux/include/stdio.h"
# 1 "/projects/or32-uclinux/include/bits/stdio_lim.h" 1
# 152 "/projects/or32-uclinux/include/stdio.h" 2



extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;






extern int remove (__const char *__filename) ;

extern int rename (__const char *__old, __const char *__new) ;




extern FILE *tmpfile (void) ;
# 183 "/projects/or32-uclinux/include/stdio.h"
extern char *tmpnam (char *__s) ;




extern char *tmpnam_r (char *__s) ;
# 200 "/projects/or32-uclinux/include/stdio.h"
extern char *tempnam (__const char *__dir, __const char *__pfx)
     __attribute__ ((__malloc__));




extern int fclose (FILE *__stream) ;

extern int fflush (FILE *__stream) ;



extern int fflush_unlocked (FILE *__stream) ;
# 224 "/projects/or32-uclinux/include/stdio.h"
extern FILE *fopen (__const char *__restrict __filename,
                    __const char *__restrict __modes) ;

extern FILE *freopen (__const char *__restrict __filename,
                      __const char *__restrict __modes,
                      FILE *__restrict __stream) ;
# 254 "/projects/or32-uclinux/include/stdio.h"
extern FILE *fdopen (int __fd, __const char *__modes) ;
# 278 "/projects/or32-uclinux/include/stdio.h"
extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) ;



extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
                    int __modes, size_t __n) ;




extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
                       size_t __size) ;


extern void setlinebuf (FILE *__stream) ;




extern int fprintf (FILE *__restrict __stream,
                    __const char *__restrict __format, ...) ;

extern int printf (__const char *__restrict __format, ...) ;

extern int sprintf (char *__restrict __s,
                    __const char *__restrict __format, ...) ;


extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
                     __gnuc_va_list __arg) ;

extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg)
     ;

extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
                     __gnuc_va_list __arg) ;



extern int snprintf (char *__restrict __s, size_t __maxlen,
                     __const char *__restrict __format, ...)
     __attribute__ ((__format__ (__printf__, 3, 4)));

extern int vsnprintf (char *__restrict __s, size_t __maxlen,
                      __const char *__restrict __format, __gnuc_va_list __arg)
     __attribute__ ((__format__ (__printf__, 3, 0)));
# 349 "/projects/or32-uclinux/include/stdio.h"
extern int fscanf (FILE *__restrict __stream,
                   __const char *__restrict __format, ...) ;

extern int scanf (__const char *__restrict __format, ...) ;

extern int sscanf (__const char *__restrict __s,
                   __const char *__restrict __format, ...) ;
# 375 "/projects/or32-uclinux/include/stdio.h"
extern int fgetc (FILE *__stream) ;
extern int getc (FILE *__stream) ;


extern int getchar (void) ;
# 389 "/projects/or32-uclinux/include/stdio.h"
extern int getc_unlocked (FILE *__stream) ;
extern int getchar_unlocked (void) ;




extern int fgetc_unlocked (FILE *__stream) ;




extern int fputc (int __c, FILE *__stream) ;
extern int putc (int __c, FILE *__stream) ;


extern int putchar (int __c) ;
# 414 "/projects/or32-uclinux/include/stdio.h"
extern int fputc_unlocked (int __c, FILE *__stream) ;




extern int putc_unlocked (int __c, FILE *__stream) ;
extern int putchar_unlocked (int __c) ;





extern int getw (FILE *__stream) ;


extern int putw (int __w, FILE *__stream) ;




extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
     ;
# 446 "/projects/or32-uclinux/include/stdio.h"
extern char *gets (char *__s) ;
# 470 "/projects/or32-uclinux/include/stdio.h"
extern int fputs (__const char *__restrict __s, FILE *__restrict __stream)
     ;
# 481 "/projects/or32-uclinux/include/stdio.h"
extern int puts (__const char *__s) ;



extern int ungetc (int __c, FILE *__stream) ;



extern size_t fread (void *__restrict __ptr, size_t __size,
                     size_t __n, FILE *__restrict __stream) ;

extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
                      size_t __n, FILE *__restrict __s) ;



extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
                              size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
                               size_t __n, FILE *__restrict __stream) ;




extern int fseek (FILE *__stream, long int __off, int __whence) ;

extern long int ftell (FILE *__stream) ;

extern void rewind (FILE *__stream) ;
# 525 "/projects/or32-uclinux/include/stdio.h"
extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
     ;

extern int fsetpos (FILE *__stream, __const fpos_t *__pos) ;
# 561 "/projects/or32-uclinux/include/stdio.h"
extern void clearerr (FILE *__stream) ;

extern int feof (FILE *__stream) ;

extern int ferror (FILE *__stream) ;



extern void clearerr_unlocked (FILE *__stream) ;
extern int feof_unlocked (FILE *__stream) ;
extern int ferror_unlocked (FILE *__stream) ;




extern void perror (__const char *__s) ;




extern int sys_nerr;
extern __const char *__const sys_errlist[];
# 593 "/projects/or32-uclinux/include/stdio.h"
extern int fileno (FILE *__stream) ;






extern int fileno_unlocked (FILE *__stream) ;






extern FILE *popen (__const char *__command, __const char *__modes) ;


extern int pclose (FILE *__stream) ;





extern char *ctermid (char *__s) ;
# 643 "/projects/or32-uclinux/include/stdio.h"
extern void flockfile (FILE *__stream) ;



extern int ftrylockfile (FILE *__stream) ;


extern void funlockfile (FILE *__stream) ;
# 667 "/projects/or32-uclinux/include/stdio.h"

# 16 "devopen.c" 2
# 1 "/projects/or32-uclinux/include/stdlib.h" 1
# 35 "/projects/or32-uclinux/include/stdlib.h"
# 1 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stddef.h" 1
# 36 "/projects/or32-uclinux/include/stdlib.h" 2


# 96 "/projects/or32-uclinux/include/stdlib.h"
typedef struct
  {
    int quot;
    int rem;
  } div_t;



typedef struct
  {
    long int quot;
    long int rem;
  } ldiv_t;
# 135 "/projects/or32-uclinux/include/stdlib.h"
extern size_t __ctype_get_mb_cur_max (void) ;



extern double atof (__const char *__nptr) __attribute__ ((__pure__));

extern int atoi (__const char *__nptr) __attribute__ ((__pure__));

extern long int atol (__const char *__nptr) __attribute__ ((__pure__));



__extension__ extern long long int atoll (__const char *__nptr)
     __attribute__ ((__pure__));



extern double strtod (__const char *__restrict __nptr,
                      char **__restrict __endptr) ;
# 165 "/projects/or32-uclinux/include/stdlib.h"
extern long int strtol (__const char *__restrict __nptr,
                        char **__restrict __endptr, int __base) ;

extern unsigned long int strtoul (__const char *__restrict __nptr,
                                  char **__restrict __endptr, int __base)
     ;



__extension__
extern long long int strtoq (__const char *__restrict __nptr,
                             char **__restrict __endptr, int __base) ;

__extension__
extern unsigned long long int strtouq (__const char *__restrict __nptr,
                                       char **__restrict __endptr, int __base)
     ;






__extension__
extern long long int strtoll (__const char *__restrict __nptr,
                              char **__restrict __endptr, int __base) ;

__extension__
extern unsigned long long int strtoull (__const char *__restrict __nptr,
                                        char **__restrict __endptr, int __base)
     ;
# 253 "/projects/or32-uclinux/include/stdlib.h"
extern double __strtod_internal (__const char *__restrict __nptr,
                                 char **__restrict __endptr, int __group)
     ;
extern float __strtof_internal (__const char *__restrict __nptr,
                                char **__restrict __endptr, int __group)
     ;
extern long double __strtold_internal (__const char *__restrict __nptr,
                                       char **__restrict __endptr,
                                       int __group) ;

extern long int __strtol_internal (__const char *__restrict __nptr,
                                   char **__restrict __endptr,
                                   int __base, int __group) ;



extern unsigned long int __strtoul_internal (__const char *__restrict __nptr,
                                             char **__restrict __endptr,
                                             int __base, int __group) ;




__extension__
extern long long int __strtoll_internal (__const char *__restrict __nptr,
                                         char **__restrict __endptr,
                                         int __base, int __group) ;



__extension__
extern unsigned long long int __strtoull_internal (__const char *
                                                   __restrict __nptr,
                                                   char **__restrict __endptr,
                                                   int __base, int __group)
     ;
# 387 "/projects/or32-uclinux/include/stdlib.h"
extern char *l64a (long int __n) ;


extern long int a64l (__const char *__s) __attribute__ ((__pure__));
# 400 "/projects/or32-uclinux/include/stdlib.h"
extern long int random (void) ;


extern void srandom (unsigned int __seed) ;





extern char *initstate (unsigned int __seed, char *__statebuf,
                        size_t __statelen) ;



extern char *setstate (char *__statebuf) ;







struct random_data
  {
    int32_t *fptr;
    int32_t *rptr;
    int32_t *state;
    int rand_type;
    int rand_deg;
    int rand_sep;
    int32_t *end_ptr;
  };

extern int random_r (struct random_data *__restrict __buf,
                     int32_t *__restrict __result) ;

extern int srandom_r (unsigned int __seed, struct random_data *__buf) ;

extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
                        size_t __statelen,
                        struct random_data *__restrict __buf) ;

extern int setstate_r (char *__restrict __statebuf,
                       struct random_data *__restrict __buf) ;





extern int rand (void) ;

extern void srand (unsigned int __seed) ;



extern int rand_r (unsigned int *__seed) ;







extern double drand48 (void) ;
extern double erand48 (unsigned short int __xsubi[3]) ;


extern long int lrand48 (void) ;
extern long int nrand48 (unsigned short int __xsubi[3]) ;


extern long int mrand48 (void) ;
extern long int jrand48 (unsigned short int __xsubi[3]) ;


extern void srand48 (long int __seedval) ;
extern unsigned short int *seed48 (unsigned short int __seed16v[3]) ;
extern void lcong48 (unsigned short int __param[7]) ;





struct drand48_data
  {
    unsigned short int __x[3];
    unsigned short int __old_x[3];
    unsigned short int __c;
    unsigned short int __init;
    unsigned long long int __a;
  };


extern int drand48_r (struct drand48_data *__restrict __buffer,
                      double *__restrict __result) ;
extern int erand48_r (unsigned short int __xsubi[3],
                      struct drand48_data *__restrict __buffer,
                      double *__restrict __result) ;


extern int lrand48_r (struct drand48_data *__restrict __buffer,
                      long int *__restrict __result) ;
extern int nrand48_r (unsigned short int __xsubi[3],
                      struct drand48_data *__restrict __buffer,
                      long int *__restrict __result) ;


extern int mrand48_r (struct drand48_data *__restrict __buffer,
                      long int *__restrict __result) ;
extern int jrand48_r (unsigned short int __xsubi[3],
                      struct drand48_data *__restrict __buffer,
                      long int *__restrict __result) ;


extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
     ;

extern int seed48_r (unsigned short int __seed16v[3],
                     struct drand48_data *__buffer) ;

extern int lcong48_r (unsigned short int __param[7],
                      struct drand48_data *__buffer) ;
# 530 "/projects/or32-uclinux/include/stdlib.h"
extern void *malloc (size_t __size) __attribute__ ((__malloc__));

extern void *calloc (size_t __nmemb, size_t __size)
     __attribute__ ((__malloc__));





extern void *realloc (void *__ptr, size_t __size) __attribute__ ((__malloc__));

extern void free (void *__ptr) ;



extern void cfree (void *__ptr) ;



# 1 "/projects/or32-uclinux/include/alloca.h" 1
# 25 "/projects/or32-uclinux/include/alloca.h"
# 1 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stddef.h" 1
# 26 "/projects/or32-uclinux/include/alloca.h" 2







extern void *alloca (size_t __size) ;






# 550 "/projects/or32-uclinux/include/stdlib.h" 2




extern void *valloc (size_t __size) __attribute__ ((__malloc__));
# 564 "/projects/or32-uclinux/include/stdlib.h"
extern void abort (void) __attribute__ ((__noreturn__));



extern int atexit (void (*__func) (void)) ;
# 577 "/projects/or32-uclinux/include/stdlib.h"
extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
     ;





extern void exit (int __status) __attribute__ ((__noreturn__));
# 594 "/projects/or32-uclinux/include/stdlib.h"
extern char *getenv (__const char *__name) ;



extern char *__secure_getenv (__const char *__name) ;





extern int putenv (char *__string) ;





extern int setenv (__const char *__name, __const char *__value, int __replace)
     ;


extern int unsetenv (__const char *__name) ;






extern int clearenv (void) ;
# 630 "/projects/or32-uclinux/include/stdlib.h"
extern char *mktemp (char *__template) ;







extern int mkstemp (char *__template) ;
# 657 "/projects/or32-uclinux/include/stdlib.h"
extern char *mkdtemp (char *__template) ;




extern int system (__const char *__command) ;
# 680 "/projects/or32-uclinux/include/stdlib.h"
extern char *realpath (__const char *__restrict __name,
                       char *__restrict __resolved) ;






typedef int (*__compar_fn_t) (__const void *, __const void *);
# 697 "/projects/or32-uclinux/include/stdlib.h"
extern void *bsearch (__const void *__key, __const void *__base,
                      size_t __nmemb, size_t __size, __compar_fn_t __compar);



extern void qsort (void *__base, size_t __nmemb, size_t __size,
                   __compar_fn_t __compar);



extern int abs (int __x) __attribute__ ((__const__));
extern long int labs (long int __x) __attribute__ ((__const__));
# 718 "/projects/or32-uclinux/include/stdlib.h"
extern div_t div (int __numer, int __denom)
     __attribute__ ((__const__));
extern ldiv_t ldiv (long int __numer, long int __denom)
     __attribute__ ((__const__));
# 736 "/projects/or32-uclinux/include/stdlib.h"
extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
                   int *__restrict __sign) ;




extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
                   int *__restrict __sign) ;




extern char *gcvt (double __value, int __ndigit, char *__buf) ;




extern char *qecvt (long double __value, int __ndigit,
                    int *__restrict __decpt, int *__restrict __sign) ;
extern char *qfcvt (long double __value, int __ndigit,
                    int *__restrict __decpt, int *__restrict __sign) ;
extern char *qgcvt (long double __value, int __ndigit, char *__buf) ;




extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
                   int *__restrict __sign, char *__restrict __buf,
                   size_t __len) ;
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
                   int *__restrict __sign, char *__restrict __buf,
                   size_t __len) ;

extern int qecvt_r (long double __value, int __ndigit,
                    int *__restrict __decpt, int *__restrict __sign,
                    char *__restrict __buf, size_t __len) ;
extern int qfcvt_r (long double __value, int __ndigit,
                    int *__restrict __decpt, int *__restrict __sign,
                    char *__restrict __buf, size_t __len) ;
# 805 "/projects/or32-uclinux/include/stdlib.h"
extern int rpmatch (__const char *__response) ;
# 867 "/projects/or32-uclinux/include/stdlib.h"
extern int getloadavg (double __loadavg[], int __nelem) ;






# 17 "devopen.c" 2
# 1 "/projects/mw/markom/mw/src/include/device.h" 1
# 10 "/projects/mw/markom/mw/src/include/device.h"
# 1 "/projects/mw/markom/mw/src/include/mwtypes.h" 1
# 160 "/projects/mw/markom/mw/src/include/mwtypes.h"
    typedef unsigned char MWPIXELVAL;
# 176 "/projects/mw/markom/mw/src/include/mwtypes.h"
typedef int MWCOORD;
typedef int MWBOOL;
typedef unsigned char MWUCHAR;
typedef unsigned long MWCOLORVAL;
typedef unsigned short MWIMAGEBITS;
typedef unsigned long MWTIMEOUT;


typedef struct _mwlist {
        struct _mwlist *next;
        struct _mwlist *prev;
} MWLIST, *PMWLIST;


typedef struct _mwlisthead {
        struct _mwlist *head;
        struct _mwlist *tail;
} MWLISTHEAD, *PMWLISTHEAD;


typedef unsigned int MWKEYMOD;


typedef struct {
        MWCOORD rows;
        MWCOORD cols;
        int xdpcm;
        int ydpcm;
        int planes;
        int bpp;
        long ncolors;
        int fonts;
        int buttons;
        MWKEYMOD modifiers;
        int pixtype;
        int portrait;
        MWBOOL fbdriver;
        unsigned long rmask;
        unsigned long gmask;
        unsigned long bmask;
        MWCOORD xpos;
        MWCOORD ypos;


        int vs_width;
        int vs_height;
        int ws_width;
        int ws_height;
} MWSCREENINFO, *PMWSCREENINFO;


typedef struct {
        unsigned char * physpixels;

        unsigned char * winpixels;
        int pixtype;
        int bpp;
        int bytespp;
        int pitch;
        int x, y;
        int portrait_mode;
        MWCOORD xres;
        MWCOORD yres;
        MWCOORD xvirtres;
        MWCOORD yvirtres;
} MWWINDOWFBINFO;


typedef struct {
        int maxwidth;
        int height;
        int baseline;
        int firstchar;
        int lastchar;
        MWBOOL fixed;
        MWUCHAR widths[256];
} MWFONTINFO, *PMWFONTINFO;


typedef struct {
        char *ttname;
        char *mwname;
} MWFONTLIST, *PMWFONTLIST;
# 311 "/projects/mw/markom/mw/src/include/mwtypes.h"
typedef struct {
        long lfHeight;
        long lfWidth;
        long lfEscapement;
        long lfOrientation;
        long lfWeight;
        MWUCHAR lfItalic;
        MWUCHAR lfUnderline;
        MWUCHAR lfStrikeOut;
        MWUCHAR lfCharSet;
        MWUCHAR lfOutPrecision;
        MWUCHAR lfClipPrecision;
        MWUCHAR lfQuality;


        MWUCHAR lfRoman;
        MWUCHAR lfSerif;
        MWUCHAR lfSansSerif;
        MWUCHAR lfModern;
        MWUCHAR lfMonospace;
        MWUCHAR lfProportional;
        MWUCHAR lfOblique;
        MWUCHAR lfSmallCaps;
        MWUCHAR lfPitch;

        char lfFaceName[64];
} MWLOGFONT, *PMWLOGFONT;
# 402 "/projects/mw/markom/mw/src/include/mwtypes.h"
typedef struct {
        MWCOORD x;
        MWCOORD y;
} MWPOINT;


typedef struct {
        MWCOORD left;
        MWCOORD top;
        MWCOORD right;
        MWCOORD bottom;
} MWRECT;


typedef struct {
        int size;
        int numRects;
        int type;
        MWRECT *rects;
        MWRECT extents;
} MWCLIPREGION;
# 440 "/projects/mw/markom/mw/src/include/mwtypes.h"
typedef struct {
        MWUCHAR r;
        MWUCHAR g;
        MWUCHAR b;
} MWPALENTRY;






typedef struct {
        int width;
        int height;
        int planes;
        int bpp;
        int pitch;
        int bytesperpixel;
        int compression;
        int palsize;
        long transcolor;
        MWPALENTRY * palette;
        MWUCHAR * imagebits;
} MWIMAGEHDR, *PMWIMAGEHDR;


typedef struct {
        int id;
        int width;
        int height;
        int planes;
        int bpp;
        int pitch;
        int bytesperpixel;
        int compression;
        int palsize;
        MWPALENTRY palette[256];
} MWIMAGEINFO, *PMWIMAGEINFO;




typedef struct {
        int width;
        int height;
        MWCOORD hotx;
        MWCOORD hoty;
        MWCOLORVAL fgcolor;
        MWCOLORVAL bgcolor;
        MWIMAGEBITS image[16];
        MWIMAGEBITS mask[16];
} MWCURSOR, *PMWCURSOR;

typedef struct _mwfont * PMWFONT;
# 534 "/projects/mw/markom/mw/src/include/mwtypes.h"
typedef unsigned short MWKEY;
typedef unsigned char MWSCANCODE;
# 660 "/projects/mw/markom/mw/src/include/mwtypes.h"
typedef struct {
        int led;
        int led_mode;
} MWKBINFO, *PMWKBINFO;
# 11 "/projects/mw/markom/mw/src/include/device.h" 2
# 30 "/projects/mw/markom/mw/src/include/device.h"
typedef struct _mwscreendevice *PSD;


typedef struct {
        char * name;
        int maxwidth;
        int height;
        int ascent;
        int firstchar;
        int size;
        MWIMAGEBITS * bits;
        unsigned short *offset;
        unsigned char * width;
} MWCFONT, *PMWCFONT;


typedef struct {
        int encoding;
        MWBOOL (*GetFontInfo)(PMWFONT pfont, PMWFONTINFO pfontinfo);
        void (*GetTextSize)(PMWFONT pfont, const void *text, int cc,
                        MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase);
        void (*GetTextBits)(PMWFONT pfont, int ch, MWIMAGEBITS *retmap,
                        MWCOORD *pwidth, MWCOORD *pheight, MWCOORD *pbase);
        void (*DestroyFont)(PMWFONT pfont);
        void (*DrawText)(PMWFONT pfont, PSD psd, MWCOORD x, MWCOORD y,
                        const void *str, int count, int flags);
        void (*SetFontSize)(PMWFONT pfont, MWCOORD fontsize);
        void (*SetFontRotation)(PMWFONT pfont, int tenthdegrees);
        void (*SetFontAttr)(PMWFONT pfont, int setflags, int clrflags);
} MWFONTPROCS, *PMWFONTPROCS;


typedef struct _mwfont {
        PMWFONTPROCS fontprocs;
        MWCOORD fontsize;
        int fontrotation;
        int fontattr;

} MWFONT;





typedef struct {
        PMWFONTPROCS fontprocs;
        MWCOORD fontsize;
        int fontrotation;
        int fontattr;

        char * name;
        PMWCFONT cfont;
} MWCOREFONT, *PMWCOREFONT;




typedef struct {
        MWCOORD dstx, dsty, dstw, dsth, dst_linelen;
        MWCOORD srcx, srcy, src_linelen;
        void *pixels, *misc;
        MWPIXELVAL bg_color, fg_color;
        int gr_usebg;
} driver_gc_t;
# 104 "/projects/mw/markom/mw/src/include/device.h"
typedef struct {
        PSD dstpsd;
        MWCOORD dstx, dsty;
        MWCOORD dstw, dsth;
        MWCOORD srcx, srcy;
        MWCOORD srcw, srch;
        PSD srcpsd;
        unsigned long rop;
        PSD alphachan;
        MWPIXELVAL fgcolor;
        MWPIXELVAL bgcolor;
        MWPIXELVAL transcolor;
} MWBLITARGS, *PMWBLITARGS;



typedef struct {
        int (*Init)(PSD psd);
        void (*DrawPixel)(PSD psd, MWCOORD x, MWCOORD y, MWPIXELVAL c);
        MWPIXELVAL (*ReadPixel)(PSD psd, MWCOORD x, MWCOORD y);
        void (*DrawHorzLine)(PSD psd, MWCOORD x1, MWCOORD x2, MWCOORD y,
                        MWPIXELVAL c);
        void (*DrawVertLine)(PSD psd, MWCOORD x, MWCOORD y1, MWCOORD y2,
                        MWPIXELVAL c);
        void (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,
                        MWCOORD y2,MWPIXELVAL c);
        void (*Blit)(PSD destpsd, MWCOORD destx, MWCOORD desty, MWCOORD w,
                        MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
        void (*DrawArea)(PSD psd, driver_gc_t *gc, int op);
        void (*StretchBlit)(PSD destpsd, MWCOORD destx, MWCOORD desty,
                        MWCOORD dstw, MWCOORD dsth, PSD srcpsd, MWCOORD srcx,
                        MWCOORD srcy, MWCOORD srcw, MWCOORD srch, long op);
} SUBDRIVER, *PSUBDRIVER;





typedef struct _mwscreendevice {
        MWCOORD xres;
        MWCOORD yres;
        MWCOORD xvirtres;
        MWCOORD yvirtres;
        int planes;
        int bpp;
        int linelen;

        int size;
        long ncolors;
        int pixtype;
        int flags;
        void * addr;

        PSD (*Open)(PSD psd);
        void (*Close)(PSD psd);
        void (*GetScreenInfo)(PSD psd,PMWSCREENINFO psi);
        void (*SetPalette)(PSD psd,int first,int count,MWPALENTRY *pal);
        void (*DrawPixel)(PSD psd,MWCOORD x,MWCOORD y,MWPIXELVAL c);
        MWPIXELVAL (*ReadPixel)(PSD psd,MWCOORD x,MWCOORD y);
        void (*DrawHorzLine)(PSD psd,MWCOORD x1,MWCOORD x2,MWCOORD y,
                        MWPIXELVAL c);
        void (*DrawVertLine)(PSD psd,MWCOORD x,MWCOORD y1,MWCOORD y2,
                        MWPIXELVAL c);
        void (*FillRect)(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
                        MWPIXELVAL c);
        PMWCOREFONT builtin_fonts;




        void (*Blit)(PSD destpsd,MWCOORD destx,MWCOORD desty,MWCOORD w,
                        MWCOORD h,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long op);
        void (*PreSelect)(PSD psd);
        void (*DrawArea)(PSD psd, driver_gc_t *gc, int op);
        int (*SetIOPermissions)(PSD psd);
        PSD (*AllocateMemGC)(PSD psd);
        MWBOOL (*MapMemGC)(PSD mempsd,MWCOORD w,MWCOORD h,int planes,int bpp,
                        int linelen,int size,void *addr);
        void (*FreeMemGC)(PSD mempsd);
        void (*StretchBlit)(PSD destpsd,MWCOORD destx,MWCOORD desty,
                        MWCOORD destw,MWCOORD desth,PSD srcpsd,MWCOORD srcx,
                        MWCOORD srcy,MWCOORD srcw,MWCOORD srch,long op);
        void (*SetPortrait)(PSD psd,int portraitmode);
        int portrait;
        PSUBDRIVER orgsubdriver;
} SCREENDEVICE;
# 200 "/projects/mw/markom/mw/src/include/device.h"
typedef struct _mousedevice {
        int (*Open)(struct _mousedevice *);
        void (*Close)(void);
        int (*GetButtonInfo)(void);
        void (*GetDefaultAccel)(int *pscale,int *pthresh);
        int (*Read)(MWCOORD *dx,MWCOORD *dy,MWCOORD *dz,int *bp);
        int (*Poll)(void);
} MOUSEDEVICE;


typedef struct _kbddevice {
        int (*Open)(struct _kbddevice *pkd);
        void (*Close)(void);
        void (*GetModifierInfo)(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);
        int (*Read)(MWKEY *buf,MWKEYMOD *modifiers,MWSCANCODE *scancode);
        int (*Poll)(void);
} KBDDEVICE;







typedef struct {
        MWCOORD x;
        MWCOORD y;
        MWCOORD width;
        MWCOORD height;
} MWCLIPRECT;
# 422 "/projects/mw/markom/mw/src/include/device.h"
PSD GdOpenScreen(void);
void GdCloseScreen(PSD psd);
int GdSetPortraitMode(PSD psd, int portraitmode);
int GdSetMode(int mode);
MWBOOL GdSetUseBackground(MWBOOL flag);
MWPIXELVAL GdSetForeground(MWPIXELVAL fg);
MWPIXELVAL GdSetBackground(MWPIXELVAL bg);
void GdResetPalette(void);
void GdSetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
int GdGetPalette(PSD psd,int first, int count, MWPALENTRY *palette);
MWPIXELVAL GdFindColor(MWCOLORVAL c);
MWPIXELVAL GdFindNearestColor(MWPALENTRY *pal, int size, MWCOLORVAL cr);
int GdCaptureScreen(char *path);
void GdGetScreenInfo(PSD psd,PMWSCREENINFO psi);
void GdPoint(PSD psd,MWCOORD x, MWCOORD y);
void GdLine(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
                MWBOOL bDrawLastPoint);
void GdRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
void GdFillRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
void GdBitmap(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
                MWIMAGEBITS *imagebits);
MWBOOL GdColorInPalette(MWCOLORVAL cr,MWPALENTRY *palette,int palsize);
void GdMakePaletteConversionTable(PSD psd,MWPALENTRY *palette,int palsize,
                MWPIXELVAL *convtable,int fLoadType);
void GdDrawImage(PSD psd,MWCOORD x, MWCOORD y, PMWIMAGEHDR pimage);
void GdPoly(PSD psd,int count, MWPOINT *points);
void GdFillPoly(PSD psd,int count, MWPOINT *points);
void GdReadArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
                MWPIXELVAL *pixels);
void GdArea(PSD psd,MWCOORD x,MWCOORD y,MWCOORD width,MWCOORD height,
                void *pixels, int pixtype);
void GdTranslateArea(MWCOORD width, MWCOORD height, void *in, int inpixtype,
                MWCOORD inpitch, void *out, int outpixtype, int outpitch);
void GdCopyArea(PSD psd,MWCOORD srcx,MWCOORD srcy,MWCOORD width,
                MWCOORD height, MWCOORD destx, MWCOORD desty);
void GdBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD width,
                MWCOORD height,PSD srcpsd,MWCOORD srcx,MWCOORD srcy,long rop);
void GdStretchBlit(PSD dstpsd, MWCOORD dstx, MWCOORD dsty, MWCOORD dstw,
                MWCOORD dsth, PSD srcpsd, MWCOORD srcx, MWCOORD srcy,
                MWCOORD srcw, MWCOORD srch, long rop);
int GdCalcMemGCAlloc(PSD psd, unsigned int width, unsigned int height,
                int planes, int bpp, int *size, int *linelen);
extern SCREENDEVICE scrdev;



void GdArcAngle(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
                MWCOORD angle1, MWCOORD angle2, int type);

void GdArc(PSD psd, MWCOORD x0, MWCOORD y0, MWCOORD rx, MWCOORD ry,
                MWCOORD ax, MWCOORD ay, MWCOORD bx, MWCOORD by, int type);
void GdEllipse(PSD psd,MWCOORD x, MWCOORD y, MWCOORD rx, MWCOORD ry,
                MWBOOL fill);


void GdClearFontList(void);
int GdAddFont(char *fndry, char *family, char *fontname, PMWLOGFONT lf,
                  unsigned int flags);
PMWFONT GdSetFont(PMWFONT pfont);
PMWFONT GdCreateFont(PSD psd, const char *name, MWCOORD height,
                const PMWLOGFONT plogfont);
MWCOORD GdSetFontSize(PMWFONT pfont, MWCOORD fontsize);
void GdGetFontList(MWFONTLIST ***list, int *num);
void GdFreeFontList(MWFONTLIST ***list, int num);
int GdSetFontRotation(PMWFONT pfont, int tenthdegrees);
int GdSetFontAttr(PMWFONT pfont, int setflags, int clrflags);
void GdDestroyFont(PMWFONT pfont);
MWBOOL GdGetFontInfo(PMWFONT pfont, PMWFONTINFO pfontinfo);
int GdConvertEncoding(const void *istr, int iflags, int cc, void *ostr,
                int oflags);
void GdGetTextSize(PMWFONT pfont, const void *str, int cc, MWCOORD *pwidth,
                MWCOORD *pheight, MWCOORD *pbase, int flags);
int GdGetTextSizeEx(PMWFONT pfont, const void *str, int cc,
                int nMaxExtent, int *lpnFit, int *alpDx, MWCOORD *pwidth,
                MWCOORD *pheight, MWCOORD *pbase, int flags);
void GdText(PSD psd,MWCOORD x,MWCOORD y,const void *str,int count,int flags);


void GdSetClipRects(PSD psd,int count,MWCLIPRECT *table);
MWBOOL GdClipPoint(PSD psd,MWCOORD x,MWCOORD y);
int GdClipArea(PSD psd,MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2);
extern MWCOORD clipminx, clipminy, clipmaxx, clipmaxy;


void GdSetClipRegion(PSD psd, MWCLIPREGION *reg);


MWBOOL GdPtInRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
int GdRectInRegion(MWCLIPREGION *rgn, const MWRECT *rect);
MWBOOL GdEqualRegion(MWCLIPREGION *r1, MWCLIPREGION *r2);
MWBOOL GdEmptyRegion(MWCLIPREGION *rgn);
MWCLIPREGION *GdAllocRegion(void);
MWCLIPREGION *GdAllocRectRegion(MWCOORD left,MWCOORD top,MWCOORD right,MWCOORD bottom);
MWCLIPREGION *GdAllocRectRegionIndirect(MWRECT *prc);
void GdSetRectRegion(MWCLIPREGION *rgn, MWCOORD left, MWCOORD top,
                MWCOORD right, MWCOORD bottom);
void GdSetRectRegionIndirect(MWCLIPREGION *rgn, MWRECT *prc);
void GdDestroyRegion(MWCLIPREGION *rgn);
void GdOffsetRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
int GdGetRegionBox(MWCLIPREGION *rgn, MWRECT *prc);
void GdUnionRectWithRegion(const MWRECT *rect, MWCLIPREGION *rgn);
void GdSubtractRectFromRegion(const MWRECT *rect, MWCLIPREGION *rgn);
void GdCopyRegion(MWCLIPREGION *d, MWCLIPREGION *s);
void GdIntersectRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
void GdUnionRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
void GdSubtractRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);
void GdXorRegion(MWCLIPREGION *d, MWCLIPREGION *s1, MWCLIPREGION *s2);


MWCLIPREGION *GdAllocPolygonRegion(MWPOINT *points, int count, int mode);
MWCLIPREGION *GdAllocPolyPolygonRegion(MWPOINT *points, int *count,
                int nbpolygons, int mode);


int GdOpenMouse(void);
void GdCloseMouse(void);
void GdGetButtonInfo(int *buttons);
void GdRestrictMouse(MWCOORD newminx,MWCOORD newminy,MWCOORD newmaxx,
                MWCOORD newmaxy);
void GdSetAccelMouse(int newthresh, int newscale);
void GdMoveMouse(MWCOORD newx, MWCOORD newy);
int GdReadMouse(MWCOORD *px, MWCOORD *py, int *pb);
void GdMoveCursor(MWCOORD x, MWCOORD y);
MWBOOL GdGetCursorPos(MWCOORD *px, MWCOORD *py);
void GdSetCursor(PMWCURSOR pcursor);
int GdShowCursor(PSD psd);
int GdHideCursor(PSD psd);
void GdCheckCursor(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2);
void GdFixCursor(PSD psd);
extern MOUSEDEVICE mousedev;


int GdOpenKeyboard(void);
void GdCloseKeyboard(void);
void GdGetModifierInfo(MWKEYMOD *modifiers, MWKEYMOD *curmodifiers);
int GdReadKeyboard(MWKEY *buf, MWKEYMOD *modifiers, MWSCANCODE *scancode);
extern KBDDEVICE kbddev;



int GdLoadImageFromBuffer(PSD psd, void *buffer, int size, int flags);
void GdDrawImageFromBuffer(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
                 MWCOORD height, void *buffer, int size, int flags);
void GdDrawImageFromFile(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
                MWCOORD height, char *path, int flags);
int GdLoadImageFromFile(PSD psd, char *path, int flags);
void GdDrawImageToFit(PSD psd, MWCOORD x, MWCOORD y, MWCOORD width,
                MWCOORD height, int id);
void GdFreeImage(int id);
MWBOOL GdGetImageInfo(int id, PMWIMAGEINFO pii);
void GdStretchImage(PMWIMAGEHDR src, MWCLIPRECT *srcrect, PMWIMAGEHDR dst,
                MWCLIPRECT *dstrect);





void * GdItemAlloc(unsigned int size);
void GdListAdd(PMWLISTHEAD pHead,PMWLIST pItem);
void GdListInsert(PMWLISTHEAD pHead,PMWLIST pItem);
void GdListRemove(PMWLISTHEAD pHead,PMWLIST pItem);
# 591 "/projects/mw/markom/mw/src/include/device.h"
# 1 "/projects/or32-uclinux/include/sys/time.h" 1
# 26 "/projects/or32-uclinux/include/sys/time.h"
# 1 "/projects/or32-uclinux/include/time.h" 1
# 27 "/projects/or32-uclinux/include/sys/time.h" 2

# 1 "/projects/or32-uclinux/include/bits/time.h" 1
# 29 "/projects/or32-uclinux/include/sys/time.h" 2




typedef __suseconds_t suseconds_t;





# 56 "/projects/or32-uclinux/include/sys/time.h"
struct timezone
  {
    int tz_minuteswest;
    int tz_dsttime;
  };

typedef struct timezone *__restrict __timezone_ptr_t;
# 72 "/projects/or32-uclinux/include/sys/time.h"
extern int gettimeofday (struct timeval *__restrict __tv,
                         __timezone_ptr_t __tz) ;




extern int settimeofday (__const struct timeval *__tv,
                         __const struct timezone *__tz) ;





extern int adjtime (__const struct timeval *__delta,
                    struct timeval *__olddelta) ;




enum __itimer_which
  {

    ITIMER_REAL = 0,


    ITIMER_VIRTUAL = 1,



    ITIMER_PROF = 2

  };



struct itimerval
  {

    struct timeval it_interval;

    struct timeval it_value;
  };






typedef int __itimer_which_t;




extern int getitimer (__itimer_which_t __which,
                      struct itimerval *__value) ;




extern int setitimer (__itimer_which_t __which,
                      __const struct itimerval *__restrict __new,
                      struct itimerval *__restrict __old) ;



extern int utimes (__const char *__file, __const struct timeval __tvp[2])
     ;
# 171 "/projects/or32-uclinux/include/sys/time.h"

# 592 "/projects/mw/markom/mw/src/include/device.h" 2

typedef void (*MWTIMERCB)(void *);




typedef struct mw_timer MWTIMER;
struct mw_timer {
        struct timeval timeout;
        MWTIMERCB callback;
        void *arg;
        MWTIMER *next;
        MWTIMER *prev;
    int type;
    MWTIMEOUT period;
};

MWTIMER *GdAddTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
MWTIMER *GdAddPeriodicTimer(MWTIMEOUT timeout, MWTIMERCB callback, void *arg);
void GdDestroyTimer(MWTIMER *timer);
MWTIMER *GdFindTimer(void *arg);
MWBOOL GdGetNextTimeout(struct timeval *tv, MWTIMEOUT timeout);
MWBOOL GdTimeout(void);




int GdError(const char *format, ...);
int GdErrorNull(const char *format, ...);
# 18 "devopen.c" 2
# 1 "/projects/mw/markom/mw/src/include/swap.h" 1







# 1 "/projects/or32-uclinux/include/byteswap.h" 1
# 23 "/projects/or32-uclinux/include/byteswap.h"
# 1 "/projects/or32-uclinux/include/bits/byteswap.h" 1
# 24 "/projects/or32-uclinux/include/byteswap.h" 2
# 9 "/projects/mw/markom/mw/src/include/swap.h" 2
# 19 "devopen.c" 2
# 32 "devopen.c"
       MWPIXELVAL gr_foreground;
       MWPIXELVAL gr_background;
       MWBOOL gr_usebg;
       int gr_mode = 0;
           MWPALENTRY gr_palette[256];
           int gr_firstuserpalentry;
           int gr_nextpalentry;
static int gr_pixtype;
static long gr_ncolors;




PSD
GdOpenScreen(void)
{
        PSD psd;
        MWPALENTRY * stdpal;
        MWSCREENINFO sinfo;

        psd = scrdev.Open(&scrdev);
        if (!psd)
                return ((void *)0);
        GdGetScreenInfo(psd, &sinfo);
        gr_pixtype = sinfo.pixtype;
        gr_ncolors = sinfo.ncolors;


        gr_firstuserpalentry = (int)psd->ncolors;


        switch((int)psd->ncolors) {


        case 2:
        {
                extern MWPALENTRY mwstdpal1[2];
                stdpal = mwstdpal1;
        }
        break;



        case 4:
        {
                extern MWPALENTRY mwstdpal2[4];
                stdpal = mwstdpal2;
        }
        break;




        case 8:
        case 16:
        {
                extern MWPALENTRY mwstdpal4[16];
                stdpal = mwstdpal4;
        }
        break;



        case 256:
        {
                extern MWPALENTRY mwstdpal8[256];





                gr_firstuserpalentry = 24;

                stdpal = mwstdpal8;
        }
        break;


        default:

                gr_firstuserpalentry = 0;
                stdpal = ((void *)0);
        }


        GdResetPalette();
        GdSetPalette(psd, 0, (int)psd->ncolors, stdpal);
# 127 "devopen.c"
        GdSetMode(0);
        GdSetForeground(GdFindColor(((MWCOLORVAL)(((unsigned char)(255)| ((unsigned short)((unsigned char)(255))<<8))| (((unsigned long)(unsigned char)(255))<<16)))));
        GdSetBackground(GdFindColor(((MWCOLORVAL)(((unsigned char)(0)| ((unsigned short)((unsigned char)(0))<<8))| (((unsigned long)(unsigned char)(0))<<16)))));
        GdSetUseBackground(1);
        GdSetFont(GdCreateFont(psd, "System", 0, ((void *)0)));

        GdSetClipRegion(psd,
                GdAllocRectRegion(0, 0, psd->xvirtres, psd->yvirtres));






        psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1, 0);
        return psd;
}




void
GdCloseScreen(PSD psd)
{
        psd->Close(psd);
}


int
GdSetPortraitMode(PSD psd, int portraitmode)
{

        if (psd->SetPortrait)
                psd->SetPortrait(psd, portraitmode);
        return psd->portrait;
}




void
GdGetScreenInfo(PSD psd, PMWSCREENINFO psi)
{
        psd->GetScreenInfo(psd, psi);
        GdGetButtonInfo(&psi->buttons);
        GdGetModifierInfo(&psi->modifiers, ((void *)0));
        GdGetCursorPos(&psi->xpos, &psi->ypos);
}


void
GdResetPalette(void)
{



        gr_nextpalentry = gr_firstuserpalentry;
}


void
GdSetPalette(PSD psd, int first, int count, MWPALENTRY *palette)
{
        int i;


        if(psd->pixtype != 2)
                return;


        if(first + count > (int)psd->ncolors)
                count = (int)psd->ncolors - first;
        if(count >= 0 && first < (int)psd->ncolors) {
                psd->SetPalette(psd, first, count, palette);


                for(i=0; i<count; ++i)
                        gr_palette[i+first] = palette[i];
        }
}


int
GdGetPalette(PSD psd, int first, int count, MWPALENTRY *palette)
{
        int i;


        if(psd->pixtype != 2)
                return 0;


        if(first + count > (int)psd->ncolors)
                if( (count = (int)psd->ncolors - first) <= 0)
                        return 0;

        for(i=0; i<count; ++i)
                *palette++ = gr_palette[i+first];

        return count;
}




MWPIXELVAL
GdFindColor(MWCOLORVAL c)
{




        switch(gr_pixtype) {
        case 3:
        case 4:


                return ((((c) & 0xff) << 16) | ((c) & 0xff00) | (((c) & 0xff0000) >> 16));

        case 5:


                return ((((c) & 0xf8) << 8) | (((c) & 0xfc00) >> 5) | (((c) & 0xf80000) >> 19));

        case 6:


                return ((((c) & 0xf8) << 7) | (((c) & 0xf800) >> 6) | (((c) & 0xf80000) >> 19));

        case 7:


                return (((c) & 0xe0) | (((c) & 0xe000) >> 11) | (((c) & 0xc00000) >> 22));
        }







        if(c & 0x01000000)
                return (c & 0xff);


        return GdFindNearestColor(gr_palette, (int)gr_ncolors, c);
}





MWPIXELVAL
GdFindNearestColor(MWPALENTRY *pal, int size, MWCOLORVAL cr)
{
        MWPALENTRY * rgb;
        int r, g, b;
        int R, G, B;
        long diff = 0x7fffffffL;
        long sq;
        int best = 0;

        r = ((cr) & 0xff);
        g = (((cr) >> 8) & 0xff);
        b = (((cr) >> 16) & 0xff);
        for(rgb=pal; diff && rgb < &pal[size]; ++rgb) {
                R = rgb->r - r;
                G = rgb->g - g;
                B = rgb->b - b;


                sq = abs(R) + abs(G) + abs(B);







                if(sq < diff) {
                        best = rgb - pal;
                        if((diff = sq) == 0)
                                return best;
                }
        }
        return best;
}


# 1 "/projects/or32-uclinux/include/unistd.h" 1
# 28 "/projects/or32-uclinux/include/unistd.h"

# 175 "/projects/or32-uclinux/include/unistd.h"
# 1 "/projects/or32-uclinux/include/bits/posix_opt.h" 1
# 176 "/projects/or32-uclinux/include/unistd.h" 2
# 199 "/projects/or32-uclinux/include/unistd.h"
# 1 "/projects/or32-uclinux/lib/gcc-lib/or32-uclinux/3.1/include/stddef.h" 1
# 200 "/projects/or32-uclinux/include/unistd.h" 2
# 240 "/projects/or32-uclinux/include/unistd.h"
typedef __intptr_t intptr_t;






typedef __socklen_t socklen_t;
# 260 "/projects/or32-uclinux/include/unistd.h"
extern int access (__const char *__name, int __type) ;
# 291 "/projects/or32-uclinux/include/unistd.h"
extern __off_t lseek (int __fd, __off_t __offset, int __whence) ;
# 307 "/projects/or32-uclinux/include/unistd.h"
extern int close (int __fd) ;



extern ssize_t read (int __fd, void *__buf, size_t __nbytes) ;


extern ssize_t write (int __fd, __const void *__buf, size_t __n) ;
# 354 "/projects/or32-uclinux/include/unistd.h"
extern int pipe (int __pipedes[2]) ;
# 363 "/projects/or32-uclinux/include/unistd.h"
extern unsigned int alarm (unsigned int __seconds) ;
# 372 "/projects/or32-uclinux/include/unistd.h"
extern unsigned int sleep (unsigned int __seconds) ;






extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
     ;



extern int usleep (__useconds_t __useconds) ;





extern int pause (void) ;



extern int chown (__const char *__file, __uid_t __owner, __gid_t __group)
     ;



extern int fchown (int __fd, __uid_t __owner, __gid_t __group) ;




extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group)
     ;




extern int chdir (__const char *__path) ;



extern int fchdir (int __fd) ;
# 424 "/projects/or32-uclinux/include/unistd.h"
extern char *getcwd (char *__buf, size_t __size) ;
# 438 "/projects/or32-uclinux/include/unistd.h"
extern char *getwd (char *__buf) ;




extern int dup (int __fd) ;


extern int dup2 (int __fd, int __fd2) ;


extern char **__environ;







extern int execve (__const char *__path, char *__const __argv[],
                   char *__const __envp[]) ;
# 470 "/projects/or32-uclinux/include/unistd.h"
extern int execv (__const char *__path, char *__const __argv[]) ;



extern int execle (__const char *__path, __const char *__arg, ...) ;



extern int execl (__const char *__path, __const char *__arg, ...) ;



extern int execvp (__const char *__file, char *__const __argv[]) ;




extern int execlp (__const char *__file, __const char *__arg, ...) ;




extern int nice (int __inc) ;




extern void _exit (int __status) __attribute__ ((__noreturn__));





# 1 "/projects/or32-uclinux/include/bits/confname.h" 1
# 25 "/projects/or32-uclinux/include/bits/confname.h"
enum
  {
    _PC_LINK_MAX,

    _PC_MAX_CANON,

    _PC_MAX_INPUT,

    _PC_NAME_MAX,

    _PC_PATH_MAX,

    _PC_PIPE_BUF,

    _PC_CHOWN_RESTRICTED,

    _PC_NO_TRUNC,

    _PC_VDISABLE,

    _PC_SYNC_IO,

    _PC_ASYNC_IO,

    _PC_PRIO_IO,

    _PC_SOCK_MAXBUF,

    _PC_FILESIZEBITS,

    _PC_REC_INCR_XFER_SIZE,

    _PC_REC_MAX_XFER_SIZE,

    _PC_REC_MIN_XFER_SIZE,

    _PC_REC_XFER_ALIGN,

    _PC_ALLOC_SIZE_MIN,

    _PC_SYMLINK_MAX

  };


enum
  {
    _SC_ARG_MAX,

    _SC_CHILD_MAX,

    _SC_CLK_TCK,

    _SC_NGROUPS_MAX,

    _SC_OPEN_MAX,

    _SC_STREAM_MAX,

    _SC_TZNAME_MAX,

    _SC_JOB_CONTROL,

    _SC_SAVED_IDS,

    _SC_REALTIME_SIGNALS,

    _SC_PRIORITY_SCHEDULING,

    _SC_TIMERS,

    _SC_ASYNCHRONOUS_IO,

    _SC_PRIORITIZED_IO,

    _SC_SYNCHRONIZED_IO,

    _SC_FSYNC,

    _SC_MAPPED_FILES,

    _SC_MEMLOCK,

    _SC_MEMLOCK_RANGE,

    _SC_MEMORY_PROTECTION,

    _SC_MESSAGE_PASSING,

    _SC_SEMAPHORES,

    _SC_SHARED_MEMORY_OBJECTS,

    _SC_AIO_LISTIO_MAX,

    _SC_AIO_MAX,

    _SC_AIO_PRIO_DELTA_MAX,

    _SC_DELAYTIMER_MAX,

    _SC_MQ_OPEN_MAX,

    _SC_MQ_PRIO_MAX,

    _SC_VERSION,

    _SC_PAGESIZE,


    _SC_RTSIG_MAX,

    _SC_SEM_NSEMS_MAX,

    _SC_SEM_VALUE_MAX,

    _SC_SIGQUEUE_MAX,

    _SC_TIMER_MAX,




    _SC_BC_BASE_MAX,

    _SC_BC_DIM_MAX,

    _SC_BC_SCALE_MAX,

    _SC_BC_STRING_MAX,

    _SC_COLL_WEIGHTS_MAX,

    _SC_EQUIV_CLASS_MAX,

    _SC_EXPR_NEST_MAX,

    _SC_LINE_MAX,

    _SC_RE_DUP_MAX,

    _SC_CHARCLASS_NAME_MAX,


    _SC_2_VERSION,

    _SC_2_C_BIND,

    _SC_2_C_DEV,

    _SC_2_FORT_DEV,

    _SC_2_FORT_RUN,

    _SC_2_SW_DEV,

    _SC_2_LOCALEDEF,


    _SC_PII,

    _SC_PII_XTI,

    _SC_PII_SOCKET,

    _SC_PII_INTERNET,

    _SC_PII_OSI,

    _SC_POLL,

    _SC_SELECT,

    _SC_UIO_MAXIOV,

    _SC_IOV_MAX = _SC_UIO_MAXIOV,

    _SC_PII_INTERNET_STREAM,

    _SC_PII_INTERNET_DGRAM,

    _SC_PII_OSI_COTS,

    _SC_PII_OSI_CLTS,

    _SC_PII_OSI_M,

    _SC_T_IOV_MAX,



    _SC_THREADS,

    _SC_THREAD_SAFE_FUNCTIONS,

    _SC_GETGR_R_SIZE_MAX,

    _SC_GETPW_R_SIZE_MAX,

    _SC_LOGIN_NAME_MAX,

    _SC_TTY_NAME_MAX,

    _SC_THREAD_DESTRUCTOR_ITERATIONS,

    _SC_THREAD_KEYS_MAX,

    _SC_THREAD_STACK_MIN,

    _SC_THREAD_THREADS_MAX,

    _SC_THREAD_ATTR_STACKADDR,

    _SC_THREAD_ATTR_STACKSIZE,

    _SC_THREAD_PRIORITY_SCHEDULING,

    _SC_THREAD_PRIO_INHERIT,

    _SC_THREAD_PRIO_PROTECT,

    _SC_THREAD_PROCESS_SHARED,


    _SC_NPROCESSORS_CONF,

    _SC_NPROCESSORS_ONLN,

    _SC_PHYS_PAGES,

    _SC_AVPHYS_PAGES,

    _SC_ATEXIT_MAX,

    _SC_PASS_MAX,


    _SC_XOPEN_VERSION,

    _SC_XOPEN_XCU_VERSION,

    _SC_XOPEN_UNIX,

    _SC_XOPEN_CRYPT,

    _SC_XOPEN_ENH_I18N,

    _SC_XOPEN_SHM,


    _SC_2_CHAR_TERM,

    _SC_2_C_VERSION,

    _SC_2_UPE,


    _SC_XOPEN_XPG2,

    _SC_XOPEN_XPG3,

    _SC_XOPEN_XPG4,


    _SC_CHAR_BIT,

    _SC_CHAR_MAX,

    _SC_CHAR_MIN,

    _SC_INT_MAX,

    _SC_INT_MIN,

    _SC_LONG_BIT,

    _SC_WORD_BIT,

    _SC_MB_LEN_MAX,

    _SC_NZERO,

    _SC_SSIZE_MAX,

    _SC_SCHAR_MAX,

    _SC_SCHAR_MIN,

    _SC_SHRT_MAX,

    _SC_SHRT_MIN,

    _SC_UCHAR_MAX,

    _SC_UINT_MAX,

    _SC_ULONG_MAX,

    _SC_USHRT_MAX,


    _SC_NL_ARGMAX,

    _SC_NL_LANGMAX,

    _SC_NL_MSGMAX,

    _SC_NL_NMAX,

    _SC_NL_SETMAX,

    _SC_NL_TEXTMAX,


    _SC_XBS5_ILP32_OFF32,

    _SC_XBS5_ILP32_OFFBIG,

    _SC_XBS5_LP64_OFF64,

    _SC_XBS5_LPBIG_OFFBIG,


    _SC_XOPEN_LEGACY,

    _SC_XOPEN_REALTIME,

    _SC_XOPEN_REALTIME_THREADS,


    _SC_ADVISORY_INFO,

    _SC_BARRIERS,

    _SC_BASE,

    _SC_C_LANG_SUPPORT,

    _SC_C_LANG_SUPPORT_R,

    _SC_CLOCK_SELECTION,

    _SC_CPUTIME,

    _SC_THREAD_CPUTIME,

    _SC_DEVICE_IO,

    _SC_DEVICE_SPECIFIC,

    _SC_DEVICE_SPECIFIC_R,

    _SC_FD_MGMT,

    _SC_FIFO,

    _SC_PIPE,

    _SC_FILE_ATTRIBUTES,

    _SC_FILE_LOCKING,

    _SC_FILE_SYSTEM,

    _SC_MONOTONIC_CLOCK,

    _SC_MULTI_PROCESS,

    _SC_SINGLE_PROCESS,

    _SC_NETWORKING,

    _SC_READER_WRITER_LOCKS,

    _SC_SPIN_LOCKS,

    _SC_REGEXP,

    _SC_REGEX_VERSION,

    _SC_SHELL,

    _SC_SIGNALS,

    _SC_SPAWN,

    _SC_SPORADIC_SERVER,

    _SC_THREAD_SPORADIC_SERVER,

    _SC_SYSTEM_DATABASE,

    _SC_SYSTEM_DATABASE_R,

    _SC_TIMEOUTS,

    _SC_TYPED_MEMORY_OBJECTS,

    _SC_USER_GROUPS,

    _SC_USER_GROUPS_R,

    _SC_2_PBS,

    _SC_2_PBS_ACCOUNTING,

    _SC_2_PBS_LOCATE,

    _SC_2_PBS_MESSAGE,

    _SC_2_PBS_TRACK,

    _SC_SYMLOOP_MAX,

    _SC_STREAMS,

    _SC_2_PBS_CHECKPOINT,


    _SC_V6_ILP32_OFF32,

    _SC_V6_ILP32_OFFBIG,

    _SC_V6_LP64_OFF64,

    _SC_V6_LPBIG_OFFBIG,


    _SC_HOST_NAME_MAX,

    _SC_TRACE,

    _SC_TRACE_EVENT_FILTER,

    _SC_TRACE_INHERIT,

    _SC_TRACE_LOG

  };





enum
  {
    _CS_PATH,
# 563 "/projects/or32-uclinux/include/bits/confname.h"
    _CS_V6_WIDTH_RESTRICTED_ENVS

  };
# 504 "/projects/or32-uclinux/include/unistd.h" 2


extern long int pathconf (__const char *__path, int __name) ;


extern long int fpathconf (int __fd, int __name) ;


extern long int sysconf (int __name) __attribute__ ((__const__));



extern size_t confstr (int __name, char *__buf, size_t __len) ;




extern __pid_t getpid (void) ;


extern __pid_t getppid (void) ;




extern __pid_t getpgrp (void) ;
# 539 "/projects/or32-uclinux/include/unistd.h"
extern __pid_t __getpgid (__pid_t __pid) ;
# 548 "/projects/or32-uclinux/include/unistd.h"
extern int setpgid (__pid_t __pid, __pid_t __pgid) ;
# 565 "/projects/or32-uclinux/include/unistd.h"
extern int setpgrp (void) ;
# 583 "/projects/or32-uclinux/include/unistd.h"
extern __pid_t setsid (void) ;







extern __uid_t getuid (void) ;


extern __uid_t geteuid (void) ;


extern __gid_t getgid (void) ;


extern __gid_t getegid (void) ;




extern int getgroups (int __size, __gid_t __list[]) ;
# 617 "/projects/or32-uclinux/include/unistd.h"
extern int setuid (__uid_t __uid) ;




extern int setreuid (__uid_t __ruid, __uid_t __euid) ;




extern int seteuid (__uid_t __uid) ;






extern int setgid (__gid_t __gid) ;




extern int setregid (__gid_t __rgid, __gid_t __egid) ;




extern int setegid (__gid_t __gid) ;






extern __pid_t fork (void) ;






extern __pid_t vfork (void) ;





extern char *ttyname (int __fd) ;



extern int ttyname_r (int __fd, char *__buf, size_t __buflen) ;



extern int isatty (int __fd) ;





extern int ttyslot (void) ;




extern int link (__const char *__from, __const char *__to) ;



extern int symlink (__const char *__from, __const char *__to) ;




extern int readlink (__const char *__restrict __path, char *__restrict __buf,
                     size_t __len) ;



extern int unlink (__const char *__name) ;


extern int rmdir (__const char *__path) ;



extern __pid_t tcgetpgrp (int __fd) ;


extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) ;



extern char *getlogin (void) ;
# 721 "/projects/or32-uclinux/include/unistd.h"
extern int setlogin (__const char *__name) ;
# 730 "/projects/or32-uclinux/include/unistd.h"
# 1 "/projects/or32-uclinux/include/getopt.h" 1
# 47 "/projects/or32-uclinux/include/getopt.h"
extern char *optarg;
# 61 "/projects/or32-uclinux/include/getopt.h"
extern int optind;




extern int opterr;



extern int optopt;
# 145 "/projects/or32-uclinux/include/getopt.h"
extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
# 731 "/projects/or32-uclinux/include/unistd.h" 2







extern int gethostname (char *__name, size_t __len) ;






extern int sethostname (__const char *__name, size_t __len) ;



extern int sethostid (long int __id) ;





extern int getdomainname (char *__name, size_t __len) ;
extern int setdomainname (__const char *__name, size_t __len) ;





extern int vhangup (void) ;


extern int revoke (__const char *__file) ;







extern int profil (unsigned short int *__sample_buffer, size_t __size,
                   size_t __offset, unsigned int __scale) ;





extern int acct (__const char *__name) ;



extern char *getusershell (void) ;
extern void endusershell (void) ;
extern void setusershell (void) ;





extern int daemon (int __nochdir, int __noclose) ;






extern int chroot (__const char *__path) ;



extern char *getpass (__const char *__prompt) ;





extern int fsync (int __fd) ;






extern long int gethostid (void) ;


extern void sync (void) ;




extern int getpagesize (void) __attribute__ ((__const__));




extern int truncate (__const char *__file, __off_t __length) ;
# 845 "/projects/or32-uclinux/include/unistd.h"
extern int ftruncate (int __fd, __off_t __length) ;
# 861 "/projects/or32-uclinux/include/unistd.h"
extern int getdtablesize (void) ;
# 870 "/projects/or32-uclinux/include/unistd.h"
extern int brk (void *__addr) ;





extern void *sbrk (intptr_t __delta) ;
# 891 "/projects/or32-uclinux/include/unistd.h"
extern long int syscall (long int __sysno, ...) ;
# 911 "/projects/or32-uclinux/include/unistd.h"
extern int lockf (int __fd, int __cmd, __off_t __len) ;
# 942 "/projects/or32-uclinux/include/unistd.h"
extern int fdatasync (int __fildes) ;
# 987 "/projects/or32-uclinux/include/unistd.h"
extern int pthread_atfork (void (*__prepare) (void),
                           void (*__parent) (void),
                           void (*__child) (void)) ;



# 317 "devopen.c" 2
# 1 "/projects/or32-uclinux/include/fcntl.h" 1
# 29 "/projects/or32-uclinux/include/fcntl.h"




# 1 "/projects/or32-uclinux/include/bits/fcntl.h" 1
# 137 "/projects/or32-uclinux/include/bits/fcntl.h"
struct flock
  {
    short int l_type;
    short int l_whence;

    __off_t l_start;
    __off_t l_len;




    __pid_t l_pid;
  };
# 34 "/projects/or32-uclinux/include/fcntl.h" 2
# 61 "/projects/or32-uclinux/include/fcntl.h"
extern int fcntl (int __fd, int __cmd, ...) ;
# 75 "/projects/or32-uclinux/include/fcntl.h"
extern int open (__const char *__file, int __oflag, ...) ;
# 92 "/projects/or32-uclinux/include/fcntl.h"
extern int creat (__const char *__file, __mode_t __mode) ;
# 174 "/projects/or32-uclinux/include/fcntl.h"

# 318 "devopen.c" 2
# 328 "devopen.c"
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef long LONG;

#pragma pack(1)

typedef struct {

        BYTE bfType[2];
        DWORD bfSize;
        WORD bfReserved1;
        WORD bfReserved2;
        DWORD bfOffBits;

        DWORD BiSize;
        LONG BiWidth;
        LONG BiHeight;
        WORD BiPlanes;
        WORD BiBitCount;
        DWORD BiCompression;
        DWORD BiSizeImage;
        LONG BiXpelsPerMeter;
        LONG BiYpelsPerMeter;
        DWORD BiClrUsed;
        DWORD BiClrImportant;
} BMPHEAD;
#pragma pack()
# 372 "devopen.c"
static void
putsw(unsigned long dw, FILE *ofp)
{

        (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc(((unsigned char)dw), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = ((unsigned char)dw)) );
        dw >>= 8;
        (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc(((unsigned char)dw), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = ((unsigned char)dw)) );
}

static void
putdw(unsigned long dw, FILE *ofp)
{

        (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc(((unsigned char)dw), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = ((unsigned char)dw)) );
        dw >>= 8;
        (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc(((unsigned char)dw), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = ((unsigned char)dw)) );
        dw >>= 8;
        (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc(((unsigned char)dw), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = ((unsigned char)dw)) );
        dw >>= 8;
        (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc(((unsigned char)dw), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = ((unsigned char)dw)) );
}



int
GdCaptureScreen(char *path)
{

        int ifd, i, j;
        FILE * ofp;
        int cx, cy, extra, bpp, bytespp, ncolors, sizecolortable;
        unsigned long rmask, gmask, bmask;
        unsigned char *cptr;
        unsigned short *sptr;
        unsigned long *lptr;
        BMPHEAD bmp;
        unsigned char buf[2048*4];

        ofp = fopen(path, "wb");
        if (!ofp)
                return 1;
        ifd = open("/dev/fb0", 0);

        cx = scrdev.xvirtres;
        cy = scrdev.yvirtres;
        bpp = scrdev.bpp;
        bytespp = (bpp+7)/8;


        extra = (cx*bytespp) & 3;
        if (extra)
                extra = 4 - extra;
        ncolors = (bpp <= 8)? (1<<bpp): 0;

        sizecolortable = ncolors? ncolors*4: 3*4;
        if (bpp == 24)
                sizecolortable = 0;


        memset(&bmp, 0, sizeof(bmp));
        bmp.bfType[0] = 'B';
        bmp.bfType[1] = 'M';
        bmp.bfSize = (__extension__ ({ unsigned int __bsx = (sizeof(bmp) + sizecolortable + (long)(cx+extra)*cy*bytespp); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));
        bmp.bfOffBits = (__extension__ ({ unsigned int __bsx = (sizeof(bmp) + sizecolortable); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));
        bmp.BiSize = (__extension__ ({ unsigned int __bsx = (40); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));
        bmp.BiWidth = (__extension__ ({ unsigned int __bsx = (cx); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));
        bmp.BiHeight = (__extension__ ({ unsigned int __bsx = (cy); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));
        bmp.BiPlanes = (__extension__ ({ unsigned short int __bsx = (1); ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }));
        bmp.BiBitCount = (__extension__ ({ unsigned short int __bsx = (bpp); ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8)); }));
        bmp.BiCompression = (__extension__ ({ unsigned int __bsx = ((bpp==16 || bpp==32)? 3L: 0L); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));
        bmp.BiSizeImage = (__extension__ ({ unsigned int __bsx = ((long)(cx+extra)*cy*bytespp); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));
        bmp.BiClrUsed = (__extension__ ({ unsigned int __bsx = ((bpp <= 8)? ncolors: 0); ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >> 8) | (((__bsx) & 0x0000ff00) << 8) | (((__bsx) & 0x000000ff) << 24)); }));



        fwrite(&bmp, sizeof(bmp), 1, ofp);


        if (sizecolortable) {
                if(bpp <= 8) {

                        for(i=0; i<ncolors; i++) {
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((gr_palette[i].b), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (gr_palette[i].b)) );
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((gr_palette[i].g), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (gr_palette[i].g)) );
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((gr_palette[i].r), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (gr_palette[i].r)) );
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((0), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (0)) );
                        }
                } else {

                        switch (gr_pixtype) {
                        case 3:
                        default:
                                rmask = 0xff0000;
                                gmask = 0x00ff00;
                                bmask = 0x0000ff;
                                break;
                        case 5:
                                rmask = 0xf800;
                                gmask = 0x07e0;
                                bmask = 0x001f;
                                break;
                        case 6:
                                rmask = 0x7c00;
                                gmask = 0x03e0;
                                bmask = 0x001f;
                                break;
                        case 7:
                                rmask = 0xe0;
                                gmask = 0x1c;
                                bmask = 0x03;
                                break;
                        }
                        putdw(rmask, ofp);
                        putdw(gmask, ofp);
                        putdw(bmask, ofp);
                }
        }


        for(i=cy-1; i>=0; --i) {
                long base = sizeof(bmp) + sizecolortable + (long)i*cx*bytespp;
                fseek(ofp, base, 0);
                read(ifd, buf, cx*bytespp);
                switch (bpp) {
                case 32:
                        lptr = (unsigned long *)buf;
                        for(j=0; j<cx; ++j)
                                putdw(*lptr++, ofp);
                        break;
                case 24:
                        cptr = (unsigned char *)buf;
                        for(j=0; j<cx; ++j) {
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((*cptr++), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (*cptr++)) );
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((*cptr++), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (*cptr++)) );
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((*cptr++), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (*cptr++)) );
                        }
                        break;
                case 16:
                        sptr = (unsigned short *)buf;
                        for(j=0; j<cx; ++j)
                                putsw(*sptr++, ofp);
                        break;
                default:
                        cptr = (unsigned char *)buf;
                        for(j=0; j<cx; ++j)
                                (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((*cptr++), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (*cptr++)) );
                        break;
                }
                for(j=0; j<extra; ++j)
                        (((ofp)->bufpos >= (ofp)->bufwrite) ? fputc((0), (ofp)) : (unsigned char) (*(ofp)->bufpos++ = (0)) );
        }

        fclose(ofp);
        close(ifd);

        return 0;
}

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.