Exemple #1
0
JNIEXPORT void JNICALL Java_jtux_UClock_nanosleep(JNIEnv *env, jclass obj,
        jobject nsecs, jobject remain)
{
    jclass cls_timespec = (*env)->FindClass(env, "jtux/UProcess$s_timespec");
    struct timespec nsecs_c, remain_buf, *remain_c = &remain_buf;
    int r;
    long sec;

    if (remain == NULL)
        remain_c = NULL;
    if (!field_jtoc_long(env, cls_timespec, "tv_sec", nsecs, &sec))
        return;
    nsecs_c.tv_sec = (time_t)sec;
    if (!field_jtoc_long(env, cls_timespec, "tv_nsec", nsecs, &nsecs_c.tv_nsec))
        return;
    r = nanosleep(&nsecs_c, remain_c);
    if (r != 0 && remain_c != NULL) {
        if (!field_ctoj_long(env, cls_timespec, "tv_sec", remain, remain_c->tv_sec))
            return;
        if (!field_ctoj_long(env, cls_timespec, "tv_nsec", remain, remain_c->tv_nsec))
            return;
    }
    if (r == -1)
        JTHROW_neg1(-1);
}
Exemple #2
0
JNIEXPORT void JNICALL Java_jtux_USysVIPC_semop(JNIEnv *env, jclass obj,
  jint semid, jobjectArray sops, jint nsops)
{
	struct sembuf *sops_c;
	int i;
	jclass cls = (*env)->FindClass(env, "jtux/USysVIPC$s_sembuf");

	JTHROW_null(sops_c = malloc(nsops * sizeof(struct sembuf)))
	if (sops_c == NULL)
		return;
	for (i = 0; i < nsops; i++) {
		jobject sb_obj = (*env)->GetObjectArrayElement(env, sops, i);

		if (sb_obj == NULL) {
			free(sops_c);
			return;
		}
		if (!field_jtoc_short(env, cls, "sem_num", sb_obj, &sops_c[i].sem_num))
			return;
		if (!field_jtoc_short(env, cls, "sem_op", sb_obj, &sops_c[i].sem_op))
			return;
		if (!field_jtoc_short(env, cls, "sem_flg", sb_obj, &sops_c[i].sem_flg))
			return;
	}
	JTHROW_neg1(semop(semid, sops_c, nsops))
	free(sops_c);
}
Exemple #3
0
JNIEXPORT void JNICALL Java_jtux_UProcess_00024sigset_1t_sigfillset(JNIEnv *env, jclass obj)
{
	sigset_t set;

	if (!get_sigset(env, obj, &set))
		return;
	JTHROW_neg1(sigfillset(&set))
	(void)set_sigset(env, obj, &set);
}
Exemple #4
0
JNIEXPORT void JNICALL Java_jtux_USysVIPC_msgsnd(JNIEnv *env, jclass obj,
  jint msqid, jbyteArray msgp, jint msgsize, jint flags)
{
	void *msgp_c;

	if ((msgp_c = (*env)->GetByteArrayElements(env, msgp, NULL)) == NULL)
		return;
	JTHROW_neg1(msgsnd(msqid, msgp_c, msgsize, flags))
	(*env)->ReleaseByteArrayElements(env, msgp, msgp_c, 0);
}
Exemple #5
0
JNIEXPORT jlong JNICALL Java_jtux_USysVIPC_ftok(JNIEnv *env, jclass obj,
  jstring path, jint id)
{
	JSTR_GET_DECL(path_c, path)
	key_t k;

	JSTR_NULLTEST_V(path_c, -1)
	JTHROW_neg1(k = ftok(path_c, id))
	JSTR_REL(path_c, path)
	return k;
}
JNIEXPORT void JNICALL Java_jtux_USysVIPC_shmctl(JNIEnv *env, jclass obj,
  jint shmid, jint cmd, jobject data)
{
	struct shmid_ds data_c;
	jclass cls = (*env)->FindClass(env, "jtux/USysVIPC$s_shmid_ds");
	int r;

	if (cmd == IPC_RMID) {
		JTHROW_neg1(r = shmctl(shmid, cmd, 0));
		return;
	} 
	else{

		memset(&data_c, 0, sizeof(data_c));
		if (cmd == IPC_SET) {
			if (!field_jtoc_perm(env, cls, "shm_perm", data, &data_c.shm_perm))
				return;
		}
		JTHROW_neg1(r = shmctl(shmid, cmd, &data_c));
		if (r == -1)
			return;
		if (cmd == IPC_STAT) {
			if (!field_ctoj_perm(env, cls, "shm_perm", data, &data_c.shm_perm))
				return;
			if (!field_ctoj_int(env, cls, "shm_segsz", data, data_c.shm_segsz))
				return;
			if (!field_ctoj_long(env, cls, "shm_lpid", data, data_c.shm_lpid))
				return;
			if (!field_ctoj_long(env, cls, "shm_cpid", data, data_c.shm_cpid))
				return;
			if (!field_ctoj_int(env, cls, "shm_nattch", data, data_c.shm_nattch))
				return;
			if (!field_ctoj_long(env, cls, "shm_atime", data, data_c.shm_atime))
				return;
			if (!field_ctoj_long(env, cls, "shm_dtime", data, data_c.shm_dtime))
				return;
			if (!field_ctoj_long(env, cls, "shm_ctime", data, data_c.shm_ctime))
				return;
		}
	}
}
Exemple #7
0
JNIEXPORT jint JNICALL Java_jtux_USysVIPC_msgrcv(JNIEnv *env, jclass obj,
  jint msqid, jbyteArray msgp, jint mtextsize, jlong msgtype, jint flags)
{
	void *msgp_c;
	ssize_t nrcv;

	if ((msgp_c = (*env)->GetByteArrayElements(env, msgp, NULL)) == NULL)
		return -1;
	JTHROW_neg1(nrcv = msgrcv(msqid, msgp_c, mtextsize, msgtype, flags))
	(*env)->ReleaseByteArrayElements(env, msgp, msgp_c, 0);
	return nrcv;
}
Exemple #8
0
    if (remain == NULL)
        remain_c = NULL;
    if (!field_jtoc_long(env, cls_timespec, "tv_sec", nsecs, &sec))
        return;
    nsecs_c.tv_sec = (time_t)sec;
    if (!field_jtoc_long(env, cls_timespec, "tv_nsec", nsecs, &nsecs_c.tv_nsec))
        return;
    r = nanosleep(&nsecs_c, remain_c);
    if (r != 0 && remain_c != NULL) {
        if (!field_ctoj_long(env, cls_timespec, "tv_sec", remain, remain_c->tv_sec))
            return;
        if (!field_ctoj_long(env, cls_timespec, "tv_nsec", remain, remain_c->tv_nsec))
            return;
    }
    if (r == -1)
        JTHROW_neg1(-1);
}

JNIEXPORT jint JNICALL Java_jtux_UClock_sleep(JNIEnv *env, jclass obj,
        jint secs)
{
    return sleep(secs);
}


JNIEXPORT void JNICALL Java_jtux_UClock_usleep(JNIEnv *env, jclass obj,
        jint usecs)
{
    JTHROW_neg1(usleep(usecs))
}
Exemple #9
0
	JTHROW_neg1(r = sigismember(&set, signum))
	return r != 0;
}
#endif// all obsolete -- get rid of this stuff

JNIEXPORT void JNICALL Java_jtux_UProcess_abort(JNIEnv *env, jclass obj)
{
	abort();
}

JNIEXPORT void JNICALL Java_jtux_UProcess_chdir(JNIEnv *env, jclass obj, jstring s)
{
	JSTR_GET_DECL(s_c, s)

	JSTR_NULLTEST(s_c)
	JTHROW_neg1(chdir(s_c))
	JSTR_REL(s_c, s)
}

JNIEXPORT void JNICALL Java_jtux_UProcess_chroot(JNIEnv *env, jclass obj, jstring s)
{
	JSTR_GET_DECL(s_c, s)

	JSTR_NULLTEST(s_c)
	JTHROW_neg1(chroot(s_c))
	JSTR_REL(s_c, s)
}

JNIEXPORT jlong JNICALL Java_jtux_UProcess_clock(JNIEnv *env, jclass obj)
{
	clock_t c;
Exemple #10
0
			return;
		if (!field_ctoj_long(env, cls, "shm_lpid", data, data_c.shm_lpid))
			return;
		if (!field_ctoj_long(env, cls, "shm_cpid", data, data_c.shm_cpid))
			return;
		if (!field_ctoj_int(env, cls, "shm_nattch", data, data_c.shm_nattch))
			return;
		if (!field_ctoj_long(env, cls, "shm_atime", data, data_c.shm_atime))
			return;
		if (!field_ctoj_long(env, cls, "shm_dtime", data, data_c.shm_dtime))
			return;
		if (!field_ctoj_long(env, cls, "shm_ctime", data, data_c.shm_ctime))
			return;
	}
}

JNIEXPORT void JNICALL Java_jtux_USysVIPC_shmdt(JNIEnv *env, jclass obj,
  jlong shmaddr)
{
	JTHROW_neg1(shmdt((void *)(intptr_t)shmaddr))
}

JNIEXPORT jint JNICALL Java_jtux_USysVIPC_shmget(JNIEnv *env, jclass obj,
  jlong key, jint size, jint flags)
{
	int shmid;

	JTHROW_neg1(shmid = shmget(key, size, flags))
	return shmid;
}