Cygwin: pinfo: raise MAX_PID to 4194304
[newlib-cygwin.git] / libgloss / arc / hl-stub.c
blobc4d6ee67b4c0d381b396d0dea760979712892bfe
1 /*
2 * hl-stub.c -- provide _kill() and _getpid().
4 * Copyright (c) 2024 Synopsys Inc.
6 * The authors hereby grant permission to use, copy, modify, distribute,
7 * and license this software and its documentation for any purpose, provided
8 * that existing copyright notices are retained in all copies and that this
9 * notice is included verbatim in any distributions. No written agreement,
10 * license, or royalty fee is required for any of the authorized uses.
11 * Modifications to this software may be copyrighted by their authors
12 * and need not follow the licensing terms described here, provided that
13 * the new terms are clearly indicated on the first page of each file where
14 * they apply.
18 #include <string.h>
19 #include <errno.h>
20 #include <unistd.h>
21 #include <sys/times.h>
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <fcntl.h>
26 #include "glue.h"
29 /* If PID is equal to __MYPID, exit with sig as retcode. */
30 int
31 _kill (int pid, int sig)
33 if (pid == __MYPID)
34 _exit (sig);
36 errno = ENOSYS;
37 return -1;
41 /* Return __MYPID. */
42 int
43 _getpid (void)
45 return __MYPID;
48 /* We do not have 64-bit compatible hostlink fstat. */
49 #if defined (__ARC64__)
50 int
51 _fstat (int fd, struct stat *st)
53 memset (st, 0, sizeof (*st));
54 st->st_mode = S_IFCHR;
55 st->st_blksize = 1024;
57 return 0;
59 #endif
62 /* hostlink backend has only fstat(), so use fstat() in stat(). */
63 int
64 _stat (const char *pathname, struct stat *buf)
66 int fd;
67 int ret;
68 int saved_errno;
70 fd = open (pathname, O_RDONLY);
71 if (fd < 0)
73 /* errno is set by open(). */
74 return -1;
77 ret = fstat (fd, buf);
78 saved_errno = errno;
80 close (fd);
82 errno = saved_errno;
84 return ret;
88 /* No Metaware hostlink backend for this call. */
89 int
90 _link (const char *oldpath __attribute__ ((unused)),
91 const char *newpath __attribute__ ((unused)))
93 errno = ENOSYS;
94 return -1;