Replace semid_t with intptr_t. No function change. This is a libc/kernel

private interface and so the name change should not affect any third
party code.
This commit is contained in:
ad 2008-11-14 15:49:20 +00:00
parent a44212844f
commit 18e73e1ebe
9 changed files with 88 additions and 90 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.20 2008/04/28 20:23:02 martin Exp $ */
/* $NetBSD: sem.c,v 1.21 2008/11/14 15:49:20 ad Exp $ */
/*-
* Copyright (c) 2003, 2006, 2007 The NetBSD Foundation, Inc.
@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: sem.c,v 1.20 2008/04/28 20:23:02 martin Exp $");
__RCSID("$NetBSD: sem.c,v 1.21 2008/11/14 15:49:20 ad Exp $");
#include <sys/types.h>
#include <sys/ksem.h>
@ -78,7 +78,7 @@ struct _sem_st {
#define USEM_MAGIC 0x09fa4012
LIST_ENTRY(_sem_st) usem_list;
semid_t usem_semid; /* 0 -> user (non-shared) */
intptr_t usem_semid; /* 0 -> user (non-shared) */
#define USEM_USER 0 /* assumes kernel does not use NULL */
sem_t *usem_identity;
@ -88,7 +88,7 @@ struct _sem_st {
unsigned int usem_count;
};
static int sem_alloc(unsigned int value, semid_t semid, sem_t *semp);
static int sem_alloc(unsigned int value, intptr_t semid, sem_t *semp);
static void sem_free(sem_t sem);
static LIST_HEAD(, _sem_st) named_sems = LIST_HEAD_INITIALIZER(&named_sems);
@ -107,7 +107,7 @@ sem_free(sem_t sem)
}
static int
sem_alloc(unsigned int value, semid_t semid, sem_t *semp)
sem_alloc(unsigned int value, intptr_t semid, sem_t *semp)
{
sem_t sem;
@ -130,7 +130,7 @@ sem_alloc(unsigned int value, semid_t semid, sem_t *semp)
int
sem_init(sem_t *sem, int pshared, unsigned int value)
{
semid_t semid;
intptr_t semid;
int error;
semid = USEM_USER;
@ -181,7 +181,7 @@ sem_t *
sem_open(const char *name, int oflag, ...)
{
sem_t *sem, s;
semid_t semid;
intptr_t semid;
mode_t mode;
unsigned int value;
int error;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sem.c,v 1.4 2008/04/28 20:23:02 martin Exp $ */
/* $NetBSD: sem.c,v 1.5 2008/11/14 15:49:20 ad Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
__RCSID("$NetBSD: sem.c,v 1.4 2008/04/28 20:23:02 martin Exp $");
__RCSID("$NetBSD: sem.c,v 1.5 2008/11/14 15:49:20 ad Exp $");
/*
* If an application is linked against both librt and libpthread, the
@ -76,7 +76,7 @@ __RCSID("$NetBSD: sem.c,v 1.4 2008/04/28 20:23:02 martin Exp $");
#define sem_post _librt_sem_post
#define sem_getvalue _librt_sem_getvalue
#define _LIBC /* XXX to get semid_t type */
#define _LIBC
#include <sys/types.h>
#include <sys/ksem.h>
@ -92,11 +92,11 @@ struct _sem_st {
#define KSEM_MAGIC 0x90af0421U
LIST_ENTRY(_sem_st) ksem_list;
semid_t ksem_semid; /* 0 -> user (non-shared) */
intptr_t ksem_semid; /* 0 -> user (non-shared) */
sem_t *ksem_identity;
};
static int sem_alloc(unsigned int value, semid_t semid, sem_t *semp);
static int sem_alloc(unsigned int value, intptr_t semid, sem_t *semp);
static void sem_free(sem_t sem);
static LIST_HEAD(, _sem_st) named_sems = LIST_HEAD_INITIALIZER(&named_sems);
@ -122,7 +122,7 @@ sem_free(sem_t sem)
}
static int
sem_alloc(unsigned int value, semid_t semid, sem_t *semp)
sem_alloc(unsigned int value, intptr_t semid, sem_t *semp)
{
sem_t sem;
@ -143,7 +143,7 @@ sem_alloc(unsigned int value, semid_t semid, sem_t *semp)
int
sem_init(sem_t *sem, int pshared, unsigned int value)
{
semid_t semid;
intptr_t semid;
int error;
if (_ksem_init(value, &semid) == -1)
@ -181,7 +181,7 @@ sem_t *
sem_open(const char *name, int oflag, ...)
{
sem_t *sem, s;
semid_t semid;
intptr_t semid;
mode_t mode;
unsigned int value;
int error;

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.58 2007/07/13 20:48:39 dsl Exp $
$NetBSD: syscalls.master,v 1.59 2008/11/14 15:49:20 ad Exp $
; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -663,16 +663,16 @@
398 UNIMPL fhstatfs
399 UNIMPL nosys
#if defined(P1003_1B_SEMAPHORE) || !defined(_KERNEL)
400 NOARGS { int sys__ksem_close(semid_t id); }
401 NOARGS { int sys__ksem_post(semid_t id); }
402 NOARGS { int sys__ksem_wait(semid_t id); }
403 NOARGS { int sys__ksem_trywait(semid_t id); }
400 NOARGS { int sys__ksem_close(intptr_t id); }
401 NOARGS { int sys__ksem_post(intptr_t id); }
402 NOARGS { int sys__ksem_wait(intptr_t id); }
403 NOARGS { int sys__ksem_trywait(intptr_t id); }
404 UNIMPL ksem_init
405 UNIMPL ksem_open
406 NOARGS { int sys__ksem_unlink(const char *name); }
407 NOARGS { int sys__ksem_getvalue(semid_t id, \
407 NOARGS { int sys__ksem_getvalue(intptr_t id, \
unsigned int *value); }
408 NOARGS { int sys__ksem_destroy(semid_t id); }
408 NOARGS { int sys__ksem_destroy(intptr_t id); }
#else
400 EXCL ksem_close
401 EXCL ksem_post

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_sem.c,v 1.7 2008/04/29 06:53:02 martin Exp $ */
/* $NetBSD: netbsd32_sem.c,v 1.8 2008/11/14 15:49:20 ad Exp $ */
/*
* Copyright (c) 2006 The NetBSD Foundation.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_sem.c,v 1.7 2008/04/29 06:53:02 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_sem.c,v 1.8 2008/11/14 15:49:20 ad Exp $");
#ifdef _KERNEL_OPT
#include "opt_posix.h"
@ -50,13 +50,13 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_sem.c,v 1.7 2008/04/29 06:53:02 martin Exp
static int
netbsd32_ksem_copyout(const void *src, void *dst, size_t size)
{
const semid_t *idp = src;
netbsd32_semid_t id32, *outidp = dst;
const intptr_t *idp = src;
netbsd32_intptr_t id32, *outidp = dst;
KASSERT(size == sizeof(semid_t));
KASSERT(size == sizeof(intptr_t));
/* Returning a kernel pointer to userspace sucks badly :-( */
id32 = (netbsd32_semid_t)*idp;
id32 = (netbsd32_intptr_t)*idp;
return copyout(&id32, outidp, sizeof(id32));
}
@ -104,11 +104,11 @@ int
netbsd32__ksem_close(struct lwp *l, const struct netbsd32__ksem_close_args *uap, register_t *retval)
{
/* {
syscallarg(netbsd32_semid_t) id;
syscallarg(netbsd32_intptr_t) id;
} */
struct sys__ksem_close_args ua;
NETBSD32TOX_UAP(id, semid_t);
NETBSD32TOX_UAP(id, intptr_t);
return sys__ksem_close(l, &ua, retval);
}
@ -116,11 +116,11 @@ int
netbsd32__ksem_post(struct lwp *l, const struct netbsd32__ksem_post_args *uap, register_t *retval)
{
/* {
syscallarg(netbsd32_semid_t) id;
syscallarg(netbsd32_intptr_t) id;
} */
struct sys__ksem_post_args ua;
NETBSD32TOX_UAP(id, semid_t);
NETBSD32TOX_UAP(id, intptr_t);
return sys__ksem_post(l, &ua, retval);
}
@ -128,11 +128,11 @@ int
netbsd32__ksem_wait(struct lwp *l, const struct netbsd32__ksem_wait_args *uap, register_t *retval)
{
/* {
syscallarg(netbsd32_semid_t) id;
syscallarg(netbsd32_intptr_t) id;
} */
struct sys__ksem_wait_args ua;
NETBSD32TOX_UAP(id, semid_t);
NETBSD32TOX_UAP(id, intptr_t);
return sys__ksem_wait(l, &ua, retval);
}
@ -140,11 +140,11 @@ int
netbsd32__ksem_trywait(struct lwp *l, const struct netbsd32__ksem_trywait_args *uap, register_t *retval)
{
/* {
syscallarg(netbsd32_semid_t) id;
syscallarg(netbsd32_intptr_t) id;
} */
struct sys__ksem_trywait_args ua;
NETBSD32TOX_UAP(id, semid_t);
NETBSD32TOX_UAP(id, intptr_t);
return sys__ksem_trywait(l, &ua, retval);
}
@ -152,11 +152,11 @@ int
netbsd32__ksem_destroy(struct lwp *l, const struct netbsd32__ksem_destroy_args *uap, register_t *retval)
{
/* {
syscallarg(netbsd32_semid_t) id;
syscallarg(netbsd32_intptr_t) id;
} */
struct sys__ksem_destroy_args ua;
NETBSD32TOX_UAP(id, semid_t);
NETBSD32TOX_UAP(id, intptr_t);
return sys__ksem_destroy(l, &ua, retval);
}
@ -164,12 +164,12 @@ int
netbsd32__ksem_getvalue(struct lwp *l, const struct netbsd32__ksem_getvalue_args *uap, register_t *retval)
{
/* {
syscallarg(netbsd32_semid_t) id;
syscallarg(netbsd32_intptr_t) id;
syscallarg(netbsd32_intp) value;
} */
struct sys__ksem_getvalue_args ua;
NETBSD32TOX_UAP(id, semid_t);
NETBSD32TOX_UAP(id, intptr_t);
NETBSD32TOP_UAP(value, unsigned int);
return sys__ksem_getvalue(l, &ua, retval);
}

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.71 2008/11/12 12:36:10 ad Exp $
$NetBSD: syscalls.master,v 1.72 2008/11/14 15:49:20 ad Exp $
; from: NetBSD: syscalls.master,v 1.81 1998/07/05 08:49:50 jonathan Exp
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -381,13 +381,13 @@
248 STD { int netbsd32__ksem_open(netbsd32_charp name, int oflag, \
mode_t mode, unsigned int value, netbsd32_semidp_t idp); }
249 STD { int netbsd32__ksem_unlink(netbsd32_charp name); }
250 STD { int netbsd32__ksem_close(netbsd32_semid_t id); }
251 STD { int netbsd32__ksem_post(netbsd32_semid_t id); }
252 STD { int netbsd32__ksem_wait(netbsd32_semid_t id); }
253 STD { int netbsd32__ksem_trywait(netbsd32_semid_t id); }
254 STD { int netbsd32__ksem_getvalue(netbsd32_semid_t id, \
250 STD { int netbsd32__ksem_close(netbsd32_intptr_t id); }
251 STD { int netbsd32__ksem_post(netbsd32_intptr_t id); }
252 STD { int netbsd32__ksem_wait(netbsd32_intptr_t id); }
253 STD { int netbsd32__ksem_trywait(netbsd32_intptr_t id); }
254 STD { int netbsd32__ksem_getvalue(netbsd32_intptr_t id, \
netbsd32_intp value); }
255 STD { int netbsd32__ksem_destroy(netbsd32_semid_t id); }
255 STD { int netbsd32__ksem_destroy(netbsd32_intptr_t id); }
256 UNIMPL sys__ksem_timedwait
#else
247 EXCL sys__ksem_init

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.213 2008/11/12 14:32:34 ad Exp $
$NetBSD: syscalls.master,v 1.214 2008/11/14 15:49:21 ad Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -504,17 +504,17 @@
struct timespec *timeout); }
245 UNIMPL sys_sigqueue
246 STD { int sys_modctl(int cmd, void *arg); }
247 STD MODULAR { int sys__ksem_init(unsigned int value, semid_t *idp); }
247 STD MODULAR { int sys__ksem_init(unsigned int value, intptr_t *idp); }
248 STD MODULAR { int sys__ksem_open(const char *name, int oflag, \
mode_t mode, unsigned int value, semid_t *idp); }
mode_t mode, unsigned int value, intptr_t *idp); }
249 STD MODULAR { int sys__ksem_unlink(const char *name); }
250 STD MODULAR { int sys__ksem_close(semid_t id); }
251 STD MODULAR { int sys__ksem_post(semid_t id); }
252 STD MODULAR { int sys__ksem_wait(semid_t id); }
253 STD MODULAR { int sys__ksem_trywait(semid_t id); }
254 STD MODULAR { int sys__ksem_getvalue(semid_t id, \
250 STD MODULAR { int sys__ksem_close(intptr_t id); }
251 STD MODULAR { int sys__ksem_post(intptr_t id); }
252 STD MODULAR { int sys__ksem_wait(intptr_t id); }
253 STD MODULAR { int sys__ksem_trywait(intptr_t id); }
254 STD MODULAR { int sys__ksem_getvalue(intptr_t id, \
unsigned int *value); }
255 STD MODULAR { int sys__ksem_destroy(semid_t id); }
255 STD MODULAR { int sys__ksem_destroy(intptr_t id); }
256 UNIMPL sys__ksem_timedwait
257 STD { mqd_t sys_mq_open(const char * name, int oflag, \
mode_t mode, struct mq_attr *attr); }

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_sem.c,v 1.28 2008/11/14 13:35:25 ad Exp $ */
/* $NetBSD: uipc_sem.c,v 1.29 2008/11/14 15:49:21 ad Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.28 2008/11/14 13:35:25 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: uipc_sem.c,v 1.29 2008/11/14 15:49:21 ad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -114,7 +114,7 @@ struct ksem {
gid_t ks_gid; /* creator gid */
unsigned int ks_value; /* current value */
unsigned int ks_waiters; /* number of waiters */
semid_t ks_id; /* unique identifier */
intptr_t ks_id; /* unique identifier */
};
struct ksem_ref {
@ -139,8 +139,8 @@ static struct ksem_list ksem_hash[SEM_HASHTBL_SIZE];
static int nsems = 0;
/*
* ksem_counter is the last assigned semid_t. It needs to be COMPAT_NETBSD32
* friendly, even though semid_t itself is defined as uintptr_t.
* ksem_counter is the last assigned intptr_t. It needs to be COMPAT_NETBSD32
* friendly, even though intptr_t itself is defined as uintptr_t.
*/
static uint32_t ksem_counter = 1;
@ -284,7 +284,7 @@ ksem_perm(struct lwp *l, struct ksem *ks)
}
static struct ksem *
ksem_lookup_byid(semid_t id)
ksem_lookup_byid(intptr_t id)
{
struct ksem *ks;
@ -376,18 +376,18 @@ sys__ksem_init(struct lwp *l, const struct sys__ksem_init_args *uap, register_t
{
/* {
unsigned int value;
semid_t *idp;
intptr_t *idp;
} */
return do_ksem_init(l, SCARG(uap, value), SCARG(uap, idp), copyout);
}
int
do_ksem_init(struct lwp *l, unsigned int value, semid_t *idp,
do_ksem_init(struct lwp *l, unsigned int value, intptr_t *idp,
copyout_t docopyout)
{
struct ksem *ks;
semid_t id;
intptr_t id;
int error;
/* Note the mode does not matter for anonymous semaphores. */
@ -415,7 +415,7 @@ sys__ksem_open(struct lwp *l, const struct sys__ksem_open_args *uap, register_t
int oflag;
mode_t mode;
unsigned int value;
semid_t *idp;
intptr_t *idp;
} */
return do_ksem_open(l, SCARG(uap, name), SCARG(uap, oflag),
@ -424,13 +424,13 @@ sys__ksem_open(struct lwp *l, const struct sys__ksem_open_args *uap, register_t
int
do_ksem_open(struct lwp *l, const char *semname, int oflag, mode_t mode,
unsigned int value, semid_t *idp, copyout_t docopyout)
unsigned int value, intptr_t *idp, copyout_t docopyout)
{
char name[SEM_MAX_NAMELEN + 1];
size_t done;
int error;
struct ksem *ksnew, *ks;
semid_t id;
intptr_t id;
error = copyinstr(semname, name, sizeof(name), &done);
if (error)
@ -532,7 +532,7 @@ do_ksem_open(struct lwp *l, const char *semname, int oflag, mode_t mode,
/* We must have a read lock on the ksem_proc list! */
static struct ksem *
ksem_lookup_proc(struct ksem_proc *kp, semid_t id)
ksem_lookup_proc(struct ksem_proc *kp, intptr_t id)
{
struct ksem_ref *ksr;
@ -591,7 +591,7 @@ int
sys__ksem_close(struct lwp *l, const struct sys__ksem_close_args *uap, register_t *retval)
{
/* {
semid_t id;
intptr_t id;
} */
struct ksem_proc *kp;
struct ksem_ref *ksr;
@ -627,7 +627,7 @@ int
sys__ksem_post(struct lwp *l, const struct sys__ksem_post_args *uap, register_t *retval)
{
/* {
semid_t id;
intptr_t id;
} */
struct ksem_proc *kp;
struct ksem *ks;
@ -658,7 +658,7 @@ sys__ksem_post(struct lwp *l, const struct sys__ksem_post_args *uap, register_t
}
static int
ksem_wait(struct lwp *l, semid_t id, int tryflag)
ksem_wait(struct lwp *l, intptr_t id, int tryflag)
{
struct ksem_proc *kp;
struct ksem *ks;
@ -697,7 +697,7 @@ int
sys__ksem_wait(struct lwp *l, const struct sys__ksem_wait_args *uap, register_t *retval)
{
/* {
semid_t id;
intptr_t id;
} */
return ksem_wait(l, SCARG(uap, id), 0);
@ -707,7 +707,7 @@ int
sys__ksem_trywait(struct lwp *l, const struct sys__ksem_trywait_args *uap, register_t *retval)
{
/* {
semid_t id;
intptr_t id;
} */
return ksem_wait(l, SCARG(uap, id), 1);
@ -717,7 +717,7 @@ int
sys__ksem_getvalue(struct lwp *l, const struct sys__ksem_getvalue_args *uap, register_t *retval)
{
/* {
semid_t id;
intptr_t id;
unsigned int *value;
} */
struct ksem_proc *kp;
@ -745,7 +745,7 @@ int
sys__ksem_destroy(struct lwp *l, const struct sys__ksem_destroy_args *uap, register_t *retval)
{
/* {
semid_t id;
intptr_t id;
} */
struct ksem_proc *kp;
struct ksem_ref *ksr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ksem.h,v 1.10 2008/11/12 14:32:34 ad Exp $ */
/* $NetBSD: ksem.h,v 1.11 2008/11/14 15:49:21 ad Exp $ */
/*
* Copyright (c) 2002 Alfred Perlstein <alfred@FreeBSD.org>
@ -34,9 +34,9 @@
#ifdef _KERNEL
#define KSEM_MAX 128
int do_ksem_init(struct lwp *, unsigned int, semid_t *, copyout_t);
int do_ksem_init(struct lwp *, unsigned int, intptr_t *, copyout_t);
int do_ksem_open(struct lwp *, const char *, int, mode_t, unsigned int,
semid_t *, copyout_t);
intptr_t *, copyout_t);
extern int posix_semaphores;
extern int ksem_max;
@ -44,15 +44,15 @@ extern int ksem_max;
#ifdef _LIBC
__BEGIN_DECLS
int _ksem_close(semid_t);
int _ksem_destroy(semid_t);
int _ksem_getvalue(semid_t, int *);
int _ksem_init(unsigned int, semid_t *);
int _ksem_open(const char *, int, mode_t, unsigned int, semid_t *);
int _ksem_post(semid_t);
int _ksem_trywait(semid_t);
int _ksem_close(intptr_t);
int _ksem_destroy(intptr_t);
int _ksem_getvalue(intptr_t, int *);
int _ksem_init(unsigned int, intptr_t *);
int _ksem_open(const char *, int, mode_t, unsigned int, intptr_t *);
int _ksem_post(intptr_t);
int _ksem_trywait(intptr_t);
int _ksem_unlink(const char *);
int _ksem_wait(semid_t);
int _ksem_wait(intptr_t);
__END_DECLS
#endif /* _LIBC */

View File

@ -1,4 +1,4 @@
/* $NetBSD: types.h,v 1.80 2008/02/26 13:37:09 simonb Exp $ */
/* $NetBSD: types.h,v 1.81 2008/11/14 15:49:21 ad Exp $ */
/*-
* Copyright (c) 1982, 1986, 1991, 1993, 1994
@ -232,9 +232,7 @@ union __semun {
struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
unsigned short *array; /* array for GETALL & SETALL */
};
/* For the same reason as above */
#include <sys/stdint.h>
typedef intptr_t semid_t;
#endif /* _KERNEL || _LIBC */
/*