make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / arch / alpha / kernel / osf_sys.c
1 /*
2  *  linux/arch/alpha/kernel/osf_sys.c
3  *
4  *  Copyright (C) 1995  Linus Torvalds
5  */
6
7 /*
8  * This file handles some of the stranger OSF/1 system call interfaces.
9  * Some of the system calls expect a non-C calling standard, others have
10  * special parameter blocks..
11  */
12
13 #include <linux/errno.h>
14 #include <linux/sched.h>
15 #include <linux/kernel.h>
16 #include <linux/mm.h>
17 #include <linux/smp.h>
18 #include <linux/smp_lock.h>
19 #include <linux/stddef.h>
20 #include <linux/unistd.h>
21 #include <linux/ptrace.h>
22 #include <linux/slab.h>
23 #include <linux/user.h>
24 #include <linux/a.out.h>
25 #include <linux/utsname.h>
26 #include <linux/time.h>
27 #include <linux/timex.h>
28 #include <linux/major.h>
29 #include <linux/stat.h>
30 #include <linux/mman.h>
31 #include <linux/shm.h>
32 #include <linux/poll.h>
33 #include <linux/file.h>
34 #include <linux/types.h>
35 #include <linux/ipc.h>
36
37 #include <asm/fpu.h>
38 #include <asm/io.h>
39 #include <asm/uaccess.h>
40 #include <asm/system.h>
41 #include <asm/sysinfo.h>
42 #include <asm/hwrpb.h>
43 #include <asm/processor.h>
44
45 extern int do_pipe(int *);
46
47 extern asmlinkage unsigned long sys_brk(unsigned long);
48
49 /*
50  * Brk needs to return an error.  Still support Linux's brk(0) query idiom,
51  * which OSF programs just shouldn't be doing.  We're still not quite
52  * identical to OSF as we don't return 0 on success, but doing otherwise
53  * would require changes to libc.  Hopefully this is good enough.
54  */
55 asmlinkage unsigned long osf_brk(unsigned long brk)
56 {
57         unsigned long retval = sys_brk(brk);
58         if (brk && brk != retval)
59                 retval = -ENOMEM;
60         return retval;
61 }
62  
63 /*
64  * This is pure guess-work..
65  */
66 asmlinkage int osf_set_program_attributes(
67         unsigned long text_start, unsigned long text_len,
68         unsigned long bss_start, unsigned long bss_len)
69 {
70         struct mm_struct *mm;
71
72         lock_kernel();
73         mm = current->mm;
74         mm->end_code = bss_start + bss_len;
75         mm->brk = bss_start + bss_len;
76 #if 0
77         printk("set_program_attributes(%lx %lx %lx %lx)\n",
78                 text_start, text_len, bss_start, bss_len);
79 #endif
80         unlock_kernel();
81         return 0;
82 }
83
84 /*
85  * OSF/1 directory handling functions...
86  *
87  * The "getdents()" interface is much more sane: the "basep" stuff is
88  * braindamage (it can't really handle filesystems where the directory
89  * offset differences aren't the same as "d_reclen").
90  */
91 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
92 #define ROUND_UP(x) (((x)+3) & ~3)
93
94 struct osf_dirent {
95         unsigned int d_ino;
96         unsigned short d_reclen;
97         unsigned short d_namlen;
98         char d_name[1];
99 };
100
101 struct osf_dirent_callback {
102         struct osf_dirent *dirent;
103         long *basep;
104         int count;
105         int error;
106 };
107
108 static int osf_filldir(void *__buf, const char *name, int namlen, loff_t offset,
109                        ino_t ino, unsigned int d_type)
110 {
111         struct osf_dirent *dirent;
112         struct osf_dirent_callback *buf = (struct osf_dirent_callback *) __buf;
113         int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
114
115         buf->error = -EINVAL;   /* only used if we fail */
116         if (reclen > buf->count)
117                 return -EINVAL;
118         if (buf->basep) {
119                 put_user(offset, buf->basep);
120                 buf->basep = NULL;
121         }
122         dirent = buf->dirent;
123         put_user(ino, &dirent->d_ino);
124         put_user(namlen, &dirent->d_namlen);
125         put_user(reclen, &dirent->d_reclen);
126         copy_to_user(dirent->d_name, name, namlen);
127         put_user(0, dirent->d_name + namlen);
128         ((char *) dirent) += reclen;
129         buf->dirent = dirent;
130         buf->count -= reclen;
131         return 0;
132 }
133
134 asmlinkage int osf_getdirentries(unsigned int fd, struct osf_dirent *dirent,
135                                  unsigned int count, long *basep)
136 {
137         int error;
138         struct file *file;
139         struct osf_dirent_callback buf;
140
141         error = -EBADF;
142         file = fget(fd);
143         if (!file)
144                 goto out;
145
146         buf.dirent = dirent;
147         buf.basep = basep;
148         buf.count = count;
149         buf.error = 0;
150
151         error = vfs_readdir(file, osf_filldir, &buf);
152         if (error < 0)
153                 goto out_putf;
154
155         error = buf.error;
156         if (count != buf.count)
157                 error = count - buf.count;
158
159 out_putf:
160         fput(file);
161 out:
162         return error;
163 }
164
165 #undef ROUND_UP
166 #undef NAME_OFFSET
167
168 /*
169  * Alpha syscall convention has no problem returning negative
170  * values:
171  */
172 asmlinkage int osf_getpriority(int which, int who, int a2, int a3, int a4,
173                                int a5, struct pt_regs regs)
174 {
175         extern int sys_getpriority(int, int);
176         int prio;
177
178         /*
179          * We don't need to acquire the kernel lock here, because
180          * all of these operations are local. sys_getpriority
181          * will get the lock as required..
182          */
183         prio = sys_getpriority(which, who);
184         if (prio >= 0) {
185                 regs.r0 = 0;            /* special return: no errors */
186                 prio = 20 - prio;
187         }
188         return prio;
189 }
190
191 /*
192  * No need to acquire the kernel lock, we're local..
193  */
194 asmlinkage unsigned long sys_getxuid(int a0, int a1, int a2, int a3, int a4,
195                                      int a5, struct pt_regs regs)
196 {
197         struct task_struct * tsk = current;
198         (&regs)->r20 = tsk->euid;
199         return tsk->uid;
200 }
201
202 asmlinkage unsigned long sys_getxgid(int a0, int a1, int a2, int a3, int a4,
203                                      int a5, struct pt_regs regs)
204 {
205         struct task_struct * tsk = current;
206         (&regs)->r20 = tsk->egid;
207         return tsk->gid;
208 }
209
210 asmlinkage unsigned long sys_getxpid(int a0, int a1, int a2, int a3, int a4,
211                                      int a5, struct pt_regs regs)
212 {
213         struct task_struct *tsk = current;
214
215         /* 
216          * This isn't strictly "local" any more and we should actually
217          * acquire the kernel lock. The "p_opptr" pointer might change
218          * if the parent goes away (or due to ptrace). But any race
219          * isn't actually going to matter, as if the parent happens
220          * to change we can happily return either of the pids.
221          */
222         (&regs)->r20 = tsk->p_opptr->tgid;
223         return tsk->tgid;
224 }
225
226 asmlinkage unsigned long osf_mmap(unsigned long addr, unsigned long len,
227                unsigned long prot, unsigned long flags, unsigned long fd,
228                                   unsigned long off)
229 {
230         struct file *file = NULL;
231         unsigned long ret = -EBADF;
232
233 #if 0
234         if (flags & (_MAP_HASSEMAPHORE | _MAP_INHERIT | _MAP_UNALIGNED))
235                 printk("%s: unimplemented OSF mmap flags %04lx\n", 
236                         current->comm, flags);
237 #endif
238         if (!(flags & MAP_ANONYMOUS)) {
239                 file = fget(fd);
240                 if (!file)
241                         goto out;
242         }
243         flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
244         down_write(&current->mm->mmap_sem);
245         ret = do_mmap(file, addr, len, prot, flags, off);
246         up_write(&current->mm->mmap_sem);
247         if (file)
248                 fput(file);
249 out:
250         return ret;
251 }
252
253
254 /*
255  * The OSF/1 statfs structure is much larger, but this should
256  * match the beginning, at least.
257  */
258 struct osf_statfs {
259         short f_type;
260         short f_flags;
261         int f_fsize;
262         int f_bsize;
263         int f_blocks;
264         int f_bfree;
265         int f_bavail;
266         int f_files;
267         int f_ffree;
268         __kernel_fsid_t f_fsid;
269 } *osf_stat;
270
271 static int linux_to_osf_statfs(struct statfs *linux_stat, struct osf_statfs *osf_stat, unsigned long bufsiz)
272 {
273         struct osf_statfs tmp_stat;
274
275         tmp_stat.f_type = linux_stat->f_type;
276         tmp_stat.f_flags = 0;   /* mount flags */
277         /* Linux doesn't provide a "fundamental filesystem block size": */
278         tmp_stat.f_fsize = linux_stat->f_bsize;
279         tmp_stat.f_bsize = linux_stat->f_bsize;
280         tmp_stat.f_blocks = linux_stat->f_blocks;
281         tmp_stat.f_bfree = linux_stat->f_bfree;
282         tmp_stat.f_bavail = linux_stat->f_bavail;
283         tmp_stat.f_files = linux_stat->f_files;
284         tmp_stat.f_ffree = linux_stat->f_ffree;
285         tmp_stat.f_fsid = linux_stat->f_fsid;
286         if (bufsiz > sizeof(tmp_stat))
287                 bufsiz = sizeof(tmp_stat);
288         return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0;
289 }
290
291 static int do_osf_statfs(struct dentry * dentry, struct osf_statfs *buffer, unsigned long bufsiz)
292 {
293         struct statfs linux_stat;
294         int error = vfs_statfs(dentry->d_inode->i_sb, &linux_stat);
295         if (!error)
296                 error = linux_to_osf_statfs(&linux_stat, buffer, bufsiz);
297         return error;   
298 }
299
300 asmlinkage int osf_statfs(char *path, struct osf_statfs *buffer, unsigned long bufsiz)
301 {
302         struct nameidata nd;
303         int retval;
304
305         retval = user_path_walk(path, &nd);
306         if (!retval) {
307                 retval = do_osf_statfs(nd.dentry, buffer, bufsiz);
308                 path_release(&nd);
309         }
310         return retval;
311 }
312
313 asmlinkage int osf_fstatfs(unsigned long fd, struct osf_statfs *buffer, unsigned long bufsiz)
314 {
315         struct file *file;
316         int retval;
317
318         retval = -EBADF;
319         file = fget(fd);
320         if (file) {
321                 retval = do_osf_statfs(file->f_dentry, buffer, bufsiz);
322                 fput(file);
323         }
324         return retval;
325 }
326
327 /*
328  * Uhh.. OSF/1 mount parameters aren't exactly obvious..
329  *
330  * Although to be frank, neither are the native Linux/i386 ones..
331  */
332 struct ufs_args {
333         char *devname;
334         int flags;
335         uid_t exroot;
336 };
337
338 struct cdfs_args {
339         char *devname;
340         int flags;
341         uid_t exroot;
342 /*
343  * This has lots more here, which Linux handles with the option block
344  * but I'm too lazy to do the translation into ASCII.
345  */
346 };
347
348 struct procfs_args {
349         char *devname;
350         int flags;
351         uid_t exroot;
352 };
353
354 /*
355  * We can't actually handle ufs yet, so we translate UFS mounts to
356  * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
357  * layout is so braindead it's a major headache doing it.
358  *
359  * Just how long ago was it written? OTOH our UFS driver may be still
360  * unhappy with OSF UFS. [CHECKME]
361  */
362 static int osf_ufs_mount(char *dirname, struct ufs_args *args, int flags)
363 {
364         int retval;
365         struct cdfs_args tmp;
366         char *devname;
367
368         retval = -EFAULT;
369         if (copy_from_user(&tmp, args, sizeof(tmp)))
370                 goto out;
371         devname = getname(tmp.devname);
372         retval = PTR_ERR(devname);
373         if (IS_ERR(devname))
374                 goto out;
375         retval = do_mount(devname, dirname, "ext2", flags, NULL);
376         putname(devname);
377 out:
378         return retval;
379 }
380
381 static int osf_cdfs_mount(char *dirname, struct cdfs_args *args, int flags)
382 {
383         int retval;
384         struct cdfs_args tmp;
385         char *devname;
386
387         retval = -EFAULT;
388         if (copy_from_user(&tmp, args, sizeof(tmp)))
389                 goto out;
390         devname = getname(tmp.devname);
391         retval = PTR_ERR(devname);
392         if (IS_ERR(devname))
393                 goto out;
394         retval = do_mount(devname, dirname, "iso9660", flags, NULL);
395         putname(devname);
396 out:
397         return retval;
398 }
399
400 static int osf_procfs_mount(char *dirname, struct procfs_args *args, int flags)
401 {
402         struct procfs_args tmp;
403
404         if (copy_from_user(&tmp, args, sizeof(tmp)))
405                 return -EFAULT;
406
407         return do_mount("", dirname, "proc", flags, NULL);
408 }
409
410 asmlinkage int osf_mount(unsigned long typenr, char *path, int flag, void *data)
411 {
412         int retval = -EINVAL;
413         char *name;
414
415         lock_kernel();
416
417         name = getname(path);
418         retval = PTR_ERR(name);
419         if (IS_ERR(name))
420                 goto out;
421         switch (typenr) {
422         case 1:
423                 retval = osf_ufs_mount(name, (struct ufs_args *) data, flag);
424                 break;
425         case 6:
426                 retval = osf_cdfs_mount(name, (struct cdfs_args *) data, flag);
427                 break;
428         case 9:
429                 retval = osf_procfs_mount(name, (struct procfs_args *) data, flag);
430                 break;
431         default:
432                 printk("osf_mount(%ld, %x)\n", typenr, flag);
433         }
434         putname(name);
435 out:
436         unlock_kernel();
437         return retval;
438 }
439
440 asmlinkage int osf_utsname(char *name)
441 {
442         int error;
443
444         down_read(&uts_sem);
445         error = -EFAULT;
446         if (copy_to_user(name + 0, system_utsname.sysname, 32))
447                 goto out;
448         if (copy_to_user(name + 32, system_utsname.nodename, 32))
449                 goto out;
450         if (copy_to_user(name + 64, system_utsname.release, 32))
451                 goto out;
452         if (copy_to_user(name + 96, system_utsname.version, 32))
453                 goto out;
454         if (copy_to_user(name + 128, system_utsname.machine, 32))
455                 goto out;
456
457         error = 0;
458 out:
459         up_read(&uts_sem);      
460         return error;
461 }
462
463 asmlinkage int osf_swapon(const char *path, int flags, int lowat, int hiwat)
464 {
465         /* for now, simply ignore lowat and hiwat... */
466         return sys_swapon(path, flags);
467 }
468
469 asmlinkage unsigned long sys_getpagesize(void)
470 {
471         return PAGE_SIZE;
472 }
473
474 asmlinkage unsigned long sys_getdtablesize(void)
475 {
476         return NR_OPEN;
477 }
478
479 asmlinkage int sys_pipe(int a0, int a1, int a2, int a3, int a4, int a5,
480                         struct pt_regs regs)
481 {
482         int fd[2];
483         int error;
484
485         error = do_pipe(fd);
486         if (error)
487                 goto out;
488         (&regs)->r20 = fd[1];
489         error = fd[0];
490 out:
491         return error;
492 }
493
494 /*
495  * For compatibility with OSF/1 only.  Use utsname(2) instead.
496  */
497 asmlinkage int osf_getdomainname(char *name, int namelen)
498 {
499         unsigned len;
500         int i, error;
501
502         error = verify_area(VERIFY_WRITE, name, namelen);
503         if (error)
504                 goto out;
505
506         len = namelen;
507         if (namelen > 32)
508                 len = 32;
509
510         down_read(&uts_sem);
511         for (i = 0; i < len; ++i) {
512                 __put_user(system_utsname.domainname[i], name + i);
513                 if (system_utsname.domainname[i] == '\0')
514                         break;
515         }
516         up_read(&uts_sem);
517 out:
518         return error;
519 }
520
521
522 asmlinkage long osf_shmat(int shmid, void *shmaddr, int shmflg)
523 {
524         unsigned long raddr;
525         long err;
526
527         err = sys_shmat(shmid, shmaddr, shmflg, &raddr);
528
529         /*
530          * This works because all user-level addresses are
531          * non-negative longs!
532          */
533         return err ? err : (long)raddr;
534 }
535
536
537 /*
538  * The following stuff should move into a header file should it ever
539  * be labeled "officially supported."  Right now, there is just enough
540  * support to avoid applications (such as tar) printing error
541  * messages.  The attributes are not really implemented.
542  */
543
544 /*
545  * Values for Property list entry flag
546  */
547 #define PLE_PROPAGATE_ON_COPY           0x1     /* cp(1) will copy entry
548                                                    by default */
549 #define PLE_FLAG_MASK                   0x1     /* Valid flag values */
550 #define PLE_FLAG_ALL                    -1      /* All flag value */
551
552 struct proplistname_args {
553         unsigned int pl_mask;
554         unsigned int pl_numnames;
555         char **pl_names;
556 };
557
558 union pl_args {
559         struct setargs {
560                 char *path;
561                 long follow;
562                 long nbytes;
563                 char *buf;
564         } set;
565         struct fsetargs {
566                 long fd;
567                 long nbytes;
568                 char *buf;
569         } fset;
570         struct getargs {
571                 char *path;
572                 long follow;
573                 struct proplistname_args *name_args;
574                 long nbytes;
575                 char *buf;
576                 int *min_buf_size;
577         } get;
578         struct fgetargs {
579                 long fd;
580                 struct proplistname_args *name_args;
581                 long nbytes;
582                 char *buf;
583                 int *min_buf_size;
584         } fget;
585         struct delargs {
586                 char *path;
587                 long follow;
588                 struct proplistname_args *name_args;
589         } del;
590         struct fdelargs {
591                 long fd;
592                 struct proplistname_args *name_args;
593         } fdel;
594 };
595
596 enum pl_code {
597         PL_SET = 1, PL_FSET = 2,
598         PL_GET = 3, PL_FGET = 4,
599         PL_DEL = 5, PL_FDEL = 6
600 };
601
602 asmlinkage long osf_proplist_syscall(enum pl_code code, union pl_args *args)
603 {
604         long error;
605         int *min_buf_size_ptr;
606
607         lock_kernel();
608         switch (code) {
609         case PL_SET:
610                 error = verify_area(VERIFY_READ, &args->set.nbytes,
611                                     sizeof(args->set.nbytes));
612                 if (!error)
613                         error = args->set.nbytes;
614                 break;
615         case PL_FSET:
616                 error = verify_area(VERIFY_READ, &args->fset.nbytes,
617                                     sizeof(args->fset.nbytes));
618                 if (!error)
619                         error = args->fset.nbytes;
620                 break;
621         case PL_GET:
622                 get_user(min_buf_size_ptr, &args->get.min_buf_size);
623                 error = verify_area(VERIFY_WRITE, min_buf_size_ptr,
624                                     sizeof(*min_buf_size_ptr));
625                 if (!error)
626                         put_user(0, min_buf_size_ptr);
627                 break;
628         case PL_FGET:
629                 get_user(min_buf_size_ptr, &args->fget.min_buf_size);
630                 error = verify_area(VERIFY_WRITE, min_buf_size_ptr,
631                                     sizeof(*min_buf_size_ptr));
632                 if (!error)
633                         put_user(0, min_buf_size_ptr);
634                 break;
635         case PL_DEL:
636         case PL_FDEL:
637                 error = 0;
638                 break;
639         default:
640                 error = -EOPNOTSUPP;
641                 break;
642         };
643         unlock_kernel();
644         return error;
645 }
646
647 asmlinkage int osf_sigstack(struct sigstack *uss, struct sigstack *uoss)
648 {
649         unsigned long usp = rdusp();
650         unsigned long oss_sp = current->sas_ss_sp + current->sas_ss_size;
651         unsigned long oss_os = on_sig_stack(usp);
652         int error;
653
654         if (uss) {
655                 void *ss_sp;
656
657                 error = -EFAULT;
658                 if (get_user(ss_sp, &uss->ss_sp))
659                         goto out;
660
661                 /* If the current stack was set with sigaltstack, don't
662                    swap stacks while we are on it.  */
663                 error = -EPERM;
664                 if (current->sas_ss_sp && on_sig_stack(usp))
665                         goto out;
666
667                 /* Since we don't know the extent of the stack, and we don't
668                    track onstack-ness, but rather calculate it, we must 
669                    presume a size.  Ho hum this interface is lossy.  */
670                 current->sas_ss_sp = (unsigned long)ss_sp - SIGSTKSZ;
671                 current->sas_ss_size = SIGSTKSZ;
672         }
673
674         if (uoss) {
675                 error = -EFAULT;
676                 if (! access_ok(VERIFY_WRITE, uoss, sizeof(*uoss))
677                     || __put_user(oss_sp, &uoss->ss_sp)
678                     || __put_user(oss_os, &uoss->ss_onstack))
679                         goto out;
680         }
681
682         error = 0;
683 out:
684         return error;
685 }
686
687 /*
688  * The Linux kernel isn't good at returning values that look
689  * like negative longs (they are mistaken as error values).
690  * Until that is fixed, we need this little workaround for
691  * create_module() because it's one of the few system calls
692  * that return kernel addresses (which are negative).
693  */
694 asmlinkage unsigned long alpha_create_module(char *module_name, unsigned long size,
695                                           int a3, int a4, int a5, int a6,
696                                              struct pt_regs regs)
697 {
698         asmlinkage unsigned long sys_create_module(char *, unsigned long);
699         long retval;
700
701         lock_kernel();
702         retval = sys_create_module(module_name, size);
703         /*
704          * we get either a module address or an error number,
705          * and we know the error number is a small negative
706          * number, while the address is always negative but
707          * much larger.
708          */
709         if (retval + 1000 > 0)
710                 goto out;
711
712         /* tell entry.S:syscall_error that this is NOT an error: */
713         regs.r0 = 0;
714 out:
715         unlock_kernel();
716         return retval;
717 }
718
719 asmlinkage long osf_sysinfo(int command, char *buf, long count)
720 {
721         static char * sysinfo_table[] = {
722                 system_utsname.sysname,
723                 system_utsname.nodename,
724                 system_utsname.release,
725                 system_utsname.version,
726                 system_utsname.machine,
727                 "alpha",        /* instruction set architecture */
728                 "dummy",        /* hardware serial number */
729                 "dummy",        /* hardware manufacturer */
730                 "dummy",        /* secure RPC domain */
731         };
732         unsigned long offset;
733         char *res;
734         long len, err = -EINVAL;
735
736         offset = command-1;
737         if (offset >= sizeof(sysinfo_table)/sizeof(char *)) {
738                 /* Digital UNIX has a few unpublished interfaces here */
739                 printk("sysinfo(%d)", command);
740                 goto out;
741         }
742         
743         down_read(&uts_sem);
744         res = sysinfo_table[offset];
745         len = strlen(res)+1;
746         if (len > count)
747                 len = count;
748         if (copy_to_user(buf, res, len))
749                 err = -EFAULT;
750         else
751                 err = 0;
752         up_read(&uts_sem);
753 out:
754         return err;
755 }
756
757 asmlinkage unsigned long osf_getsysinfo(unsigned long op, void *buffer,
758                                         unsigned long nbytes,
759                                         int *start, void *arg)
760 {
761         unsigned long w;
762         struct percpu_struct *cpu;
763
764         switch (op) {
765         case GSI_IEEE_FP_CONTROL:
766                 /* Return current software fp control & status bits.  */
767                 /* Note that DU doesn't verify available space here.  */
768
769                 w = current->thread.flags & IEEE_SW_MASK;
770                 w = swcr_update_status(w, rdfpcr());
771                 if (put_user(w, (unsigned long *) buffer))
772                         return -EFAULT;
773                 return 0;
774
775         case GSI_IEEE_STATE_AT_SIGNAL:
776                 /*
777                  * Not sure anybody will ever use this weird stuff.  These
778                  * ops can be used (under OSF/1) to set the fpcr that should
779                  * be used when a signal handler starts executing.
780                  */
781                 break;
782
783         case GSI_UACPROC:
784                 if (nbytes < sizeof(unsigned int))
785                         return -EINVAL;
786                 w = (current->thread.flags >> UAC_SHIFT) & UAC_BITMASK;
787                 if (put_user(w, (unsigned int *)buffer))
788                         return -EFAULT;
789                 return 1;
790
791         case GSI_PROC_TYPE:
792                 if (nbytes < sizeof(unsigned long))
793                         return -EINVAL;
794                 cpu = (struct percpu_struct*)
795                   ((char*)hwrpb + hwrpb->processor_offset);
796                 w = cpu->type;
797                 if (put_user(w, (unsigned long *)buffer))
798                         return -EFAULT;
799                 return 1;
800
801         case GSI_GET_HWRPB:
802                 if (nbytes < sizeof(*hwrpb))
803                         return -EINVAL;
804                 if (copy_to_user(buffer, hwrpb, nbytes) != 0)
805                         return -EFAULT;
806                 return 1;
807
808         default:
809                 break;
810         }
811
812         return -EOPNOTSUPP;
813 }
814
815 asmlinkage unsigned long osf_setsysinfo(unsigned long op, void *buffer,
816                                         unsigned long nbytes,
817                                         int *start, void *arg)
818 {
819         switch (op) {
820         case SSI_IEEE_FP_CONTROL: {
821                 unsigned long swcr, fpcr;
822
823                 /* 
824                  * Alpha Architecture Handbook 4.7.7.3:
825                  * To be fully IEEE compiant, we must track the current IEEE
826                  * exception state in software, because spurrious bits can be
827                  * set in the trap shadow of a software-complete insn.
828                  */
829
830                 /* Update softare trap enable bits.  */
831                 if (get_user(swcr, (unsigned long *)buffer))
832                         return -EFAULT;
833                 current->thread.flags &= ~IEEE_SW_MASK;
834                 current->thread.flags |= swcr & IEEE_SW_MASK;
835
836                 /* Update the real fpcr.  */
837                 fpcr = rdfpcr();
838                 fpcr &= FPCR_DYN_MASK;
839                 fpcr |= ieee_swcr_to_fpcr(swcr);
840                 wrfpcr(fpcr);
841
842                 /* If any exceptions are now unmasked, send a signal.  */
843                 if (((swcr & IEEE_STATUS_MASK)
844                      >> IEEE_STATUS_TO_EXCSUM_SHIFT) & swcr) {
845                         send_sig(SIGFPE, current, 1);
846                 }
847
848                 return 0;
849         }
850
851         case SSI_IEEE_STATE_AT_SIGNAL:
852         case SSI_IEEE_IGNORE_STATE_AT_SIGNAL:
853                 /*
854                  * Not sure anybody will ever use this weird stuff.  These
855                  * ops can be used (under OSF/1) to set the fpcr that should
856                  * be used when a signal handler starts executing.
857                  */
858                 break;
859
860         case SSI_NVPAIRS: {
861                 unsigned long v, w, i;
862                 
863                 for (i = 0; i < nbytes; ++i) {
864                         if (get_user(v, 2*i + (unsigned int *)buffer))
865                                 return -EFAULT;
866                         if (get_user(w, 2*i + 1 + (unsigned int *)buffer))
867                                 return -EFAULT;
868                         switch (v) {
869                         case SSIN_UACPROC:
870                                 current->thread.flags &=
871                                         ~(UAC_BITMASK << UAC_SHIFT);
872                                 current->thread.flags |=
873                                         (w & UAC_BITMASK) << UAC_SHIFT;
874                                 break;
875  
876                         default:
877                                 return -EOPNOTSUPP;
878                         }
879                 }
880                 return 0;
881         }
882  
883         default:
884                 break;
885         }
886
887         return -EOPNOTSUPP;
888 }
889
890 /* Translations due to the fact that OSF's time_t is an int.  Which
891    affects all sorts of things, like timeval and itimerval.  */
892
893 extern struct timezone sys_tz;
894 extern int do_sys_settimeofday(struct timeval *tv, struct timezone *tz);
895 extern int do_getitimer(int which, struct itimerval *value);
896 extern int do_setitimer(int which, struct itimerval *, struct itimerval *);
897 asmlinkage int sys_utimes(char *, struct timeval *);
898 extern int do_adjtimex(struct timex *);
899
900 struct timeval32
901 {
902     int tv_sec, tv_usec;
903 };
904
905 struct itimerval32
906 {
907     struct timeval32 it_interval;
908     struct timeval32 it_value;
909 };
910
911 static inline long get_tv32(struct timeval *o, struct timeval32 *i)
912 {
913         return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
914                 (__get_user(o->tv_sec, &i->tv_sec) |
915                  __get_user(o->tv_usec, &i->tv_usec)));
916 }
917
918 static inline long put_tv32(struct timeval32 *o, struct timeval *i)
919 {
920         return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
921                 (__put_user(i->tv_sec, &o->tv_sec) |
922                  __put_user(i->tv_usec, &o->tv_usec)));
923 }
924
925 static inline long get_it32(struct itimerval *o, struct itimerval32 *i)
926 {
927         return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
928                 (__get_user(o->it_interval.tv_sec, &i->it_interval.tv_sec) |
929                  __get_user(o->it_interval.tv_usec, &i->it_interval.tv_usec) |
930                  __get_user(o->it_value.tv_sec, &i->it_value.tv_sec) |
931                  __get_user(o->it_value.tv_usec, &i->it_value.tv_usec)));
932 }
933
934 static inline long put_it32(struct itimerval32 *o, struct itimerval *i)
935 {
936         return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
937                 (__put_user(i->it_interval.tv_sec, &o->it_interval.tv_sec) |
938                  __put_user(i->it_interval.tv_usec, &o->it_interval.tv_usec) |
939                  __put_user(i->it_value.tv_sec, &o->it_value.tv_sec) |
940                  __put_user(i->it_value.tv_usec, &o->it_value.tv_usec)));
941 }
942
943 asmlinkage int osf_gettimeofday(struct timeval32 *tv, struct timezone *tz)
944 {
945         if (tv) {
946                 struct timeval ktv;
947                 do_gettimeofday(&ktv);
948                 if (put_tv32(tv, &ktv))
949                         return -EFAULT;
950         }
951         if (tz) {
952                 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
953                         return -EFAULT;
954         }
955         return 0;
956 }
957
958 asmlinkage int osf_settimeofday(struct timeval32 *tv, struct timezone *tz)
959 {
960         struct timeval ktv;
961         struct timezone ktz;
962
963         if (tv) {
964                 if (get_tv32(&ktv, tv))
965                         return -EFAULT;
966         }
967         if (tz) {
968                 if (copy_from_user(&ktz, tz, sizeof(*tz)))
969                         return -EFAULT;
970         }
971
972         return do_sys_settimeofday(tv ? &ktv : NULL, tz ? &ktz : NULL);
973 }
974
975 asmlinkage int osf_getitimer(int which, struct itimerval32 *it)
976 {
977         struct itimerval kit;
978         int error;
979
980         error = do_getitimer(which, &kit);
981         if (!error && put_it32(it, &kit))
982                 error = -EFAULT;
983
984         return error;
985 }
986
987 asmlinkage int osf_setitimer(int which, struct itimerval32 *in,
988                              struct itimerval32 *out)
989 {
990         struct itimerval kin, kout;
991         int error;
992
993         if (in) {
994                 if (get_it32(&kin, in))
995                         return -EFAULT;
996         } else
997                 memset(&kin, 0, sizeof(kin));
998
999         error = do_setitimer(which, &kin, out ? &kout : NULL);
1000         if (error || !out)
1001                 return error;
1002
1003         if (put_it32(out, &kout))
1004                 return -EFAULT;
1005
1006         return 0;
1007
1008 }
1009
1010 asmlinkage int osf_utimes(const char *filename, struct timeval32 *tvs)
1011 {
1012         char *kfilename;
1013         struct timeval ktvs[2];
1014         mm_segment_t old_fs;
1015         int ret;
1016
1017         kfilename = getname(filename);
1018         if (IS_ERR(kfilename))
1019                 return PTR_ERR(kfilename);
1020
1021         if (tvs) {
1022                 if (get_tv32(&ktvs[0], &tvs[0]) ||
1023                     get_tv32(&ktvs[1], &tvs[1]))
1024                         return -EFAULT;
1025         }
1026
1027         old_fs = get_fs();
1028         set_fs(KERNEL_DS);
1029         ret = sys_utimes(kfilename, tvs ? ktvs : 0);
1030         set_fs(old_fs);
1031
1032         putname(kfilename);
1033
1034         return ret;
1035 }
1036
1037 #define MAX_SELECT_SECONDS \
1038         ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1)
1039
1040 asmlinkage int
1041 osf_select(int n, fd_set *inp, fd_set *outp, fd_set *exp,
1042            struct timeval32 *tvp)
1043 {
1044         fd_set_bits fds;
1045         char *bits;
1046         size_t size;
1047         unsigned long timeout;
1048         int ret;
1049
1050         timeout = MAX_SCHEDULE_TIMEOUT;
1051         if (tvp) {
1052                 time_t sec, usec;
1053
1054                 if ((ret = verify_area(VERIFY_READ, tvp, sizeof(*tvp)))
1055                     || (ret = __get_user(sec, &tvp->tv_sec))
1056                     || (ret = __get_user(usec, &tvp->tv_usec)))
1057                         goto out_nofds;
1058
1059                 ret = -EINVAL;
1060                 if (sec < 0 || usec < 0)
1061                         goto out_nofds;
1062
1063                 if ((unsigned long) sec < MAX_SELECT_SECONDS) {
1064                         timeout = (usec + 1000000/HZ - 1) / (1000000/HZ);
1065                         timeout += sec * (unsigned long) HZ;
1066                 }
1067         }
1068
1069         ret = -EINVAL;
1070         if (n < 0 || n > current->files->max_fdset)
1071                 goto out_nofds;
1072
1073         /*
1074          * We need 6 bitmaps (in/out/ex for both incoming and outgoing),
1075          * since we used fdset we need to allocate memory in units of
1076          * long-words. 
1077          */
1078         ret = -ENOMEM;
1079         size = FDS_BYTES(n);
1080         bits = kmalloc(6 * size, GFP_KERNEL);
1081         if (!bits)
1082                 goto out_nofds;
1083         fds.in      = (unsigned long *)  bits;
1084         fds.out     = (unsigned long *) (bits +   size);
1085         fds.ex      = (unsigned long *) (bits + 2*size);
1086         fds.res_in  = (unsigned long *) (bits + 3*size);
1087         fds.res_out = (unsigned long *) (bits + 4*size);
1088         fds.res_ex  = (unsigned long *) (bits + 5*size);
1089
1090         if ((ret = get_fd_set(n, inp->fds_bits, fds.in)) ||
1091             (ret = get_fd_set(n, outp->fds_bits, fds.out)) ||
1092             (ret = get_fd_set(n, exp->fds_bits, fds.ex)))
1093                 goto out;
1094         zero_fd_set(n, fds.res_in);
1095         zero_fd_set(n, fds.res_out);
1096         zero_fd_set(n, fds.res_ex);
1097
1098         ret = do_select(n, &fds, &timeout);
1099
1100         /* OSF does not copy back the remaining time.  */
1101
1102         if (ret < 0)
1103                 goto out;
1104         if (!ret) {
1105                 ret = -ERESTARTNOHAND;
1106                 if (signal_pending(current))
1107                         goto out;
1108                 ret = 0;
1109         }
1110
1111         set_fd_set(n, inp->fds_bits, fds.res_in);
1112         set_fd_set(n, outp->fds_bits, fds.res_out);
1113         set_fd_set(n, exp->fds_bits, fds.res_ex);
1114
1115 out:
1116         kfree(bits);
1117 out_nofds:
1118         return ret;
1119 }
1120
1121 struct rusage32 {
1122         struct timeval32 ru_utime;      /* user time used */
1123         struct timeval32 ru_stime;      /* system time used */
1124         long    ru_maxrss;              /* maximum resident set size */
1125         long    ru_ixrss;               /* integral shared memory size */
1126         long    ru_idrss;               /* integral unshared data size */
1127         long    ru_isrss;               /* integral unshared stack size */
1128         long    ru_minflt;              /* page reclaims */
1129         long    ru_majflt;              /* page faults */
1130         long    ru_nswap;               /* swaps */
1131         long    ru_inblock;             /* block input operations */
1132         long    ru_oublock;             /* block output operations */
1133         long    ru_msgsnd;              /* messages sent */
1134         long    ru_msgrcv;              /* messages received */
1135         long    ru_nsignals;            /* signals received */
1136         long    ru_nvcsw;               /* voluntary context switches */
1137         long    ru_nivcsw;              /* involuntary " */
1138 };
1139
1140 asmlinkage int osf_getrusage(int who, struct rusage32 *ru)
1141 {
1142         struct rusage32 r;
1143
1144         if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
1145                 return -EINVAL;
1146
1147         memset(&r, 0, sizeof(r));
1148         switch (who) {
1149         case RUSAGE_SELF:
1150                 r.ru_utime.tv_sec = CT_TO_SECS(current->times.tms_utime);
1151                 r.ru_utime.tv_usec = CT_TO_USECS(current->times.tms_utime);
1152                 r.ru_stime.tv_sec = CT_TO_SECS(current->times.tms_stime);
1153                 r.ru_stime.tv_usec = CT_TO_USECS(current->times.tms_stime);
1154                 r.ru_minflt = current->min_flt;
1155                 r.ru_majflt = current->maj_flt;
1156                 r.ru_nswap = current->nswap;
1157                 break;
1158         case RUSAGE_CHILDREN:
1159                 r.ru_utime.tv_sec = CT_TO_SECS(current->times.tms_cutime);
1160                 r.ru_utime.tv_usec = CT_TO_USECS(current->times.tms_cutime);
1161                 r.ru_stime.tv_sec = CT_TO_SECS(current->times.tms_cstime);
1162                 r.ru_stime.tv_usec = CT_TO_USECS(current->times.tms_cstime);
1163                 r.ru_minflt = current->cmin_flt;
1164                 r.ru_majflt = current->cmaj_flt;
1165                 r.ru_nswap = current->cnswap;
1166                 break;
1167         default:
1168                 r.ru_utime.tv_sec = CT_TO_SECS(current->times.tms_utime +
1169                                                current->times.tms_cutime);
1170                 r.ru_utime.tv_usec = CT_TO_USECS(current->times.tms_utime +
1171                                                  current->times.tms_cutime);
1172                 r.ru_stime.tv_sec = CT_TO_SECS(current->times.tms_stime +
1173                                                current->times.tms_cstime);
1174                 r.ru_stime.tv_usec = CT_TO_USECS(current->times.tms_stime +
1175                                                  current->times.tms_cstime);
1176                 r.ru_minflt = current->min_flt + current->cmin_flt;
1177                 r.ru_majflt = current->maj_flt + current->cmaj_flt;
1178                 r.ru_nswap = current->nswap + current->cnswap;
1179                 break;
1180         }
1181
1182         return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
1183 }
1184
1185 asmlinkage int osf_wait4(pid_t pid, int *ustatus, int options,
1186                          struct rusage32 *ur)
1187 {
1188         if (!ur) {
1189                 return sys_wait4(pid, ustatus, options, NULL);
1190         } else {
1191                 struct rusage r;
1192                 int ret, status;
1193                 mm_segment_t old_fs = get_fs();
1194                 
1195                 set_fs (KERNEL_DS);
1196                 ret = sys_wait4(pid, &status, options, &r);
1197                 set_fs (old_fs);
1198
1199                 if (!access_ok(VERIFY_WRITE, ur, sizeof(*ur)))
1200                         return -EFAULT;
1201                 __put_user(r.ru_utime.tv_sec, &ur->ru_utime.tv_sec);
1202                 __put_user(r.ru_utime.tv_usec, &ur->ru_utime.tv_usec);
1203                 __put_user(r.ru_stime.tv_sec, &ur->ru_stime.tv_sec);
1204                 __put_user(r.ru_stime.tv_usec, &ur->ru_stime.tv_usec);
1205                 __put_user(r.ru_maxrss, &ur->ru_maxrss);
1206                 __put_user(r.ru_ixrss, &ur->ru_ixrss);
1207                 __put_user(r.ru_idrss, &ur->ru_idrss);
1208                 __put_user(r.ru_isrss, &ur->ru_isrss);
1209                 __put_user(r.ru_minflt, &ur->ru_minflt);
1210                 __put_user(r.ru_majflt, &ur->ru_majflt);
1211                 __put_user(r.ru_nswap, &ur->ru_nswap);
1212                 __put_user(r.ru_inblock, &ur->ru_inblock);
1213                 __put_user(r.ru_oublock, &ur->ru_oublock);
1214                 __put_user(r.ru_msgsnd, &ur->ru_msgsnd);
1215                 __put_user(r.ru_msgrcv, &ur->ru_msgrcv);
1216                 __put_user(r.ru_nsignals, &ur->ru_nsignals);
1217                 __put_user(r.ru_nvcsw, &ur->ru_nvcsw);
1218                 if (__put_user(r.ru_nivcsw, &ur->ru_nivcsw))
1219                         return -EFAULT;
1220
1221                 if (ustatus && put_user(status, ustatus))
1222                         return -EFAULT;
1223                 return ret;
1224         }
1225 }
1226
1227 /*
1228  * I don't know what the parameters are: the first one
1229  * seems to be a timeval pointer, and I suspect the second
1230  * one is the time remaining.. Ho humm.. No documentation.
1231  */
1232 asmlinkage int osf_usleep_thread(struct timeval32 *sleep, struct timeval32 *remain)
1233 {
1234         struct timeval tmp;
1235         unsigned long ticks;
1236
1237         if (get_tv32(&tmp, sleep))
1238                 goto fault;
1239
1240         ticks = tmp.tv_usec;
1241         ticks = (ticks + (1000000 / HZ) - 1) / (1000000 / HZ);
1242         ticks += tmp.tv_sec * HZ;
1243
1244         current->state = TASK_INTERRUPTIBLE;
1245         ticks = schedule_timeout(ticks);
1246
1247         if (remain) {
1248                 tmp.tv_sec = ticks / HZ;
1249                 tmp.tv_usec = ticks % HZ;
1250                 if (put_tv32(remain, &tmp))
1251                         goto fault;
1252         }
1253         
1254         return 0;
1255 fault:
1256         return -EFAULT;
1257 }
1258
1259
1260 struct timex32 {
1261         unsigned int modes;     /* mode selector */
1262         long offset;            /* time offset (usec) */
1263         long freq;              /* frequency offset (scaled ppm) */
1264         long maxerror;          /* maximum error (usec) */
1265         long esterror;          /* estimated error (usec) */
1266         int status;             /* clock command/status */
1267         long constant;          /* pll time constant */
1268         long precision;         /* clock precision (usec) (read only) */
1269         long tolerance;         /* clock frequency tolerance (ppm)
1270                                  * (read only)
1271                                  */
1272         struct timeval32 time;  /* (read only) */
1273         long tick;              /* (modified) usecs between clock ticks */
1274
1275         long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
1276         long jitter;            /* pps jitter (us) (ro) */
1277         int shift;              /* interval duration (s) (shift) (ro) */
1278         long stabil;            /* pps stability (scaled ppm) (ro) */
1279         long jitcnt;            /* jitter limit exceeded (ro) */
1280         long calcnt;            /* calibration intervals (ro) */
1281         long errcnt;            /* calibration errors (ro) */
1282         long stbcnt;            /* stability limit exceeded (ro) */
1283
1284         int  :32; int  :32; int  :32; int  :32;
1285         int  :32; int  :32; int  :32; int  :32;
1286         int  :32; int  :32; int  :32; int  :32;
1287 };
1288
1289 asmlinkage int sys_old_adjtimex(struct timex32 *txc_p)
1290 {
1291         struct timex txc;
1292         int ret;
1293
1294         /* copy relevant bits of struct timex. */
1295         if (copy_from_user(&txc, txc_p, offsetof(struct timex32, time)) ||
1296             copy_from_user(&txc.tick, &txc_p->tick, sizeof(struct timex32) - 
1297                            offsetof(struct timex32, time)))
1298           return -EFAULT;
1299
1300         ret = do_adjtimex(&txc);        
1301         if (ret < 0)
1302           return ret;
1303         
1304         /* copy back to timex32 */
1305         if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
1306             (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) - 
1307                           offsetof(struct timex32, tick))) ||
1308             (put_tv32(&txc_p->time, &txc.time)))
1309           return -EFAULT;
1310
1311         return ret;
1312 }
1313
1314 /* Get an address range which is currently unmapped.  Similar to the
1315    generic version except that we know how to honor ADDR_LIMIT_32BIT.  */
1316
1317 static unsigned long
1318 arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
1319                          unsigned long limit)
1320 {
1321         struct vm_area_struct *vma = find_vma(current->mm, addr);
1322
1323         while (1) {
1324                 /* At this point:  (!vma || addr < vma->vm_end). */
1325                 if (limit - len < addr)
1326                         return -ENOMEM;
1327                 if (!vma || addr + len <= vma->vm_start)
1328                         return addr;
1329                 addr = vma->vm_end;
1330                 vma = vma->vm_next;
1331         }
1332 }
1333
1334 unsigned long
1335 arch_get_unmapped_area(struct file *filp, unsigned long addr,
1336                        unsigned long len, unsigned long pgoff,
1337                        unsigned long flags)
1338 {
1339         unsigned long limit;
1340
1341         /* "32 bit" actually means 31 bit, since pointers sign extend.  */
1342         if (current->personality & ADDR_LIMIT_32BIT)
1343                 limit = 0x80000000;
1344         else
1345                 limit = TASK_SIZE;
1346
1347         if (len > limit)
1348                 return -ENOMEM;
1349
1350         /* First, see if the given suggestion fits.
1351
1352            The OSF/1 loader (/sbin/loader) relies on us returning an
1353            address larger than the requested if one exists, which is
1354            a terribly broken way to program.
1355
1356            That said, I can see the use in being able to suggest not
1357            merely specific addresses, but regions of memory -- perhaps
1358            this feature should be incorporated into all ports?  */
1359
1360         if (addr) {
1361                 addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
1362                 if (addr != -ENOMEM)
1363                         return addr;
1364         }
1365
1366         /* Next, try allocating at TASK_UNMAPPED_BASE.  */
1367         addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
1368                                          len, limit);
1369         if (addr != -ENOMEM)
1370                 return addr;
1371
1372         /* Finally, try allocating in low memory.  */
1373         addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
1374
1375         return addr;
1376 }
1377
1378 #ifdef CONFIG_OSF4_COMPAT
1379 extern ssize_t sys_readv(unsigned long, const struct iovec *, unsigned long);
1380 extern ssize_t sys_writev(unsigned long, const struct iovec *, unsigned long);
1381
1382 /* Clear top 32 bits of iov_len in the user's buffer for
1383    compatibility with old versions of OSF/1 where iov_len
1384    was defined as int. */
1385 static int
1386 osf_fix_iov_len(const struct iovec *iov, unsigned long count)
1387 {
1388         unsigned long i;
1389
1390         for (i = 0 ; i < count ; i++) {
1391                 int *iov_len_high = (int *)&iov[i].iov_len + 1;
1392
1393                 if (put_user(0, iov_len_high))
1394                         return -EFAULT;
1395         }
1396         return 0;
1397 }
1398
1399 asmlinkage ssize_t
1400 osf_readv(unsigned long fd, const struct iovec * vector, unsigned long count)
1401 {
1402         if (unlikely(personality(current->personality) == PER_OSF4))
1403                 if (osf_fix_iov_len(vector, count))
1404                         return -EFAULT;
1405         return sys_readv(fd, vector, count);
1406 }
1407
1408 asmlinkage ssize_t
1409 osf_writev(unsigned long fd, const struct iovec * vector, unsigned long count)
1410 {
1411         if (unlikely(personality(current->personality) == PER_OSF4))
1412                 if (osf_fix_iov_len(vector, count))
1413                         return -EFAULT;
1414         return sys_writev(fd, vector, count);
1415 }
1416
1417 #endif