Added a shared memory test.

- libposix error printing now configurable via macro definition
- shmget/at/dt tested.
This commit is contained in:
Bahadir Balban
2009-05-12 18:16:25 +03:00
parent 324481a334
commit 33fcceb2b6
24 changed files with 126 additions and 76 deletions
+7 -6
View File
@@ -12,6 +12,7 @@
#include <l4lib/arch/syslib.h>
#include <l4lib/ipcdefs.h>
#include <l4/macros.h>
#include <libposix.h>
int l4_shmget(l4id_t key, int size, int shmflg)
{
@@ -23,12 +24,12 @@ int l4_shmget(l4id_t key, int size, int shmflg)
/* Call pager with shmget() request. Check ipc error. */
if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_SHMGET)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
return err;
}
/* Check if syscall itself was successful */
if (IS_ERR(err = l4_get_retval())) {
printf("%s: SHMGET Error: %d.\n", __FUNCTION__, err);
print_err("%s: SHMGET Error: %d.\n", __FUNCTION__, err);
return err;
}
@@ -46,12 +47,12 @@ void *l4_shmat(l4id_t shmid, const void *shmaddr, int shmflg)
/* Call pager with shmget() request. Check ipc error. */
if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_SHMAT)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
return PTR_ERR(err);
}
/* Check if syscall itself was successful */
if (IS_ERR(err = l4_get_retval())) {
printf("%s: SHMAT Error: %d.\n", __FUNCTION__, err);
print_err("%s: SHMAT Error: %d.\n", __FUNCTION__, err);
return PTR_ERR(err);
}
@@ -67,12 +68,12 @@ int l4_shmdt(const void *shmaddr)
/* Call pager with shmget() request. Check ipc error. */
if ((err = l4_sendrecv(PAGER_TID, PAGER_TID, L4_IPC_TAG_SHMDT)) < 0) {
printf("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
print_err("%s: L4 IPC Error: %d.\n", __FUNCTION__, err);
return -1;
}
/* Check if syscall itself was successful */
if ((err = l4_get_retval()) < 0) {
printf("%s: SHMDT Error: %d.\n", __FUNCTION__, err);
print_err("%s: SHMDT Error: %d.\n", __FUNCTION__, err);
return -1;
}
return 0;