- /* just a sample, see the zip file for more */
-
- /*
- * Copyright (c) 2004-2005, contax. All rights reserved.
- *
- * LICENSE TERMS
- *
- * The free distribution and use of this software in both source and
- * binary form is allowed (with or without changes) provided that:
- *
- * 1. distributions of this source code include the above copyright
- * notice, this list of conditions and the following disclaimer;
- *
- * 2. distributions in binary form include the above copyright notice,
- * this list of conditions and the following disclaimer in the
- * documentation and/or other associated materials;
- *
- * DISCLAIMER
- *
- * This software is provided 'as is' with no explicit or implied
- * warranties in respect of its properties, including, but not limited to,
- * correctness and fitness for purpose.
- */
-
- #include <unistd.h>
- #include <sys/mman.h>
- #include <stdio.h>
- #include <errno.h>
- #include "destroy.h"
- #include "./lfsr/lfsr.h"
- #define _RANDOM_LOCAL
- #include "random.h"
- #undef _RANDOM_LOCAL
-
-
- LFSR_CTX *
- rand_init(int fd)
- {
- LFSR_CTX *ctx;
- uint32_t *sd;
-
- if (NULL == lfsr_alloc(ctx)) {
- perror("lfsr_alloc");
- return NULL;
- }
- if ((void *) -1 == (sd = (uint32_t *)
- mmap(0, 31 * sizeof(uint32_t), PROT_READ |
- PROT_WRITE, MAP_PRIVATE, fd, 0)))
- {
- perror("projection");
- lfsr_ctx_free(ctx);
- return NULL;
- }
- (void) lfsr_init(ctx, sd);
- munmap(sd, 31 * sizeof(uint32_t));
-
- return ctx;
- }
-
/* just a sample, see the zip file for more */
/*
* Copyright (c) 2004-2005, contax. All rights reserved.
*
* LICENSE TERMS
*
* The free distribution and use of this software in both source and
* binary form is allowed (with or without changes) provided that:
*
* 1. distributions of this source code include the above copyright
* notice, this list of conditions and the following disclaimer;
*
* 2. distributions in binary form include the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other associated materials;
*
* DISCLAIMER
*
* This software is provided 'as is' with no explicit or implied
* warranties in respect of its properties, including, but not limited to,
* correctness and fitness for purpose.
*/
#include <unistd.h>
#include <sys/mman.h>
#include <stdio.h>
#include <errno.h>
#include "destroy.h"
#include "./lfsr/lfsr.h"
#define _RANDOM_LOCAL
#include "random.h"
#undef _RANDOM_LOCAL
LFSR_CTX *
rand_init(int fd)
{
LFSR_CTX *ctx;
uint32_t *sd;
if (NULL == lfsr_alloc(ctx)) {
perror("lfsr_alloc");
return NULL;
}
if ((void *) -1 == (sd = (uint32_t *)
mmap(0, 31 * sizeof(uint32_t), PROT_READ |
PROT_WRITE, MAP_PRIVATE, fd, 0)))
{
perror("projection");
lfsr_ctx_free(ctx);
return NULL;
}
(void) lfsr_init(ctx, sd);
munmap(sd, 31 * sizeof(uint32_t));
return ctx;
}