comparison src/context.h @ 51:fadfd62d6b14

define filesystem DataGeas and ommit stdlib.h
author anatofuz
date Tue, 28 May 2019 22:27:01 +0900
parents 233a68a261fe
children 214d21c891c7
comparison
equal deleted inserted replaced
50:3931ac87d850 51:fadfd62d6b14
1 /* Context definition for llrb example */ 1 /* Context definition for llrb example */
2 #ifndef CONTEXT_H 2 #ifdef CONTEXT_H
3 #define CONTEXT_H 3 #define CONTEXT_H
4 #ifdef CBCXV6
5
6 #else
7 #include <stdlib.h> 4 #include <stdlib.h>
8 #include <pthread.h> 5 #include <pthread.h>
9 #endif
10 #ifdef USE_CUDAWorker 6 #ifdef USE_CUDAWorker
11 #include <cuda.h> 7 #include <cuda.h>
12 #include <driver_types.h> 8 #include <driver_types.h>
13 #include <cuda_runtime.h> 9 #include <cuda_runtime.h>
14 #include "helper_cuda.h" 10 #include "helper_cuda.h"
15 #endif 11 #endif
12
13 #include "use_context_numbers.h"
16 14
17 #define ALLOCATE_SIZE 20000000 15 #define ALLOCATE_SIZE 20000000
18 #define NEW(type) (type*)(calloc(1, sizeof(type))) 16 #define NEW(type) (type*)(calloc(1, sizeof(type)))
19 #define NEWN(n, type) (type*)(calloc(n, sizeof(type))) 17 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
20 18
91 GT, 89 GT,
92 LT, 90 LT,
93 }; 91 };
94 92
95 #include "c/enumData.h" 93 #include "c/enumData.h"
94 #define NDIRECT 12 //fs.h
96 95
97 struct Context { 96 struct Context {
98 enum Code next; 97 enum Code next;
99 struct Worker* worker; 98 struct Worker* worker;
100 struct TaskManager* taskManager; 99 struct TaskManager* taskManager;
438 struct SpinLock { 437 struct SpinLock {
439 volatile Int* lock; 438 volatile Int* lock;
440 struct Atomic* atomic; 439 struct Atomic* atomic;
441 struct Context* lockContext; 440 struct Context* lockContext;
442 } SpinLock; 441 } SpinLock;
442 /* CbCxv6 context*/
443 struct Inode {
444 uint dev; // Device number
445 uint inum; // Inode number
446 int ref; // Reference count
447 int flags; // I_BUSY, I_VALID
448
449 short type; // copy of disk inode
450 short major;
451 short minor;
452 short nlink;
453 uint size;
454 uint addrs[NDIRECT+1];
455 } Inode;
456 struct Uinteger {
457 uint value;
458 } Uinteger;
459 struct Short {
460 short value;
461 } Short;
462 struct String {
463 char* string;
464 } String;
465 // fs.h ---
466 struct SuperBlock {
467 uint size; // Size of file system image (blocks)
468 uint nblocks; // Number of data blocks
469 uint ninodes; // Number of inodes.
470 uint nlog; // Number of log blocks
471 } SuperBlock;
472 struct Dinode {
473 short type; // copy of disk inode
474 short major;
475 short minor;
476 short nlink;
477 uint size;
478 uint addrs[NDIRECT+1];
479 } Dinode;
480 struct Dirent {
481 ushort inum;
482 char name[DIRSIZ];
483 } Dirent;
484 // --- fs.h
443 }; // union Data end this is necessary for context generator 485 }; // union Data end this is necessary for context generator
486
444 typedef union Data Data; 487 typedef union Data Data;
445 488
446 #include "c/typedefData.h" 489 #include "c/typedefData.h"
447 490
448 #include "c/extern.h" 491 #include "c/extern.h"