1 // Included by gensyscalls. 2 3 typedef int AlignmentType; 4 static const char* kAlignmentType = "int"; 5 static const int kAlignment = sizeof(AlignmentType); 6 7 // ReturnTypeCreator 8 template<typename T> 9 class ReturnTypeCreator { 10 public: 11 static void Create(Syscall* syscall, const char* name) 12 { 13 int size = sizeof(T); 14 int usedSize = align_to_type<AlignmentType>(size); 15 const char* alignmentType 16 = (size != usedSize && size < kAlignment ? kAlignmentType : 0); 17 18 syscall->SetReturnType(name, size, usedSize, alignmentType); 19 } 20 }; 21 22 template<> 23 class ReturnTypeCreator<void> { 24 public: 25 static void Create(Syscall* syscall, const char* name) 26 { 27 syscall->SetReturnType(name, 0, 0, 0); 28 } 29 }; 30 31 // ParameterCreator 32 template<typename T> 33 class ParameterCreator { 34 public: 35 static void Create(Syscall* syscall, const char* typeName, 36 const char* parameterName) 37 { 38 // compute offset 39 int offset = 0; 40 if (Parameter* previous = syscall->LastParameter()) 41 offset = previous->Offset() + previous->UsedSize(); 42 43 int size = sizeof(T); 44 int usedSize = align_to_type<AlignmentType>(size); 45 const char* alignmentType 46 = (size != usedSize && size < kAlignment ? kAlignmentType : 0); 47 48 syscall->AddParameter(typeName, parameterName, size, usedSize, offset, 49 alignmentType); 50 } 51 }; 52