file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/232956055.c
// RUN: clang -o %t %s --target=%arm_triple -fuse-ld=lld // RUN: llvm-mctoll -d -I /usr/include/stdio.h %t // RUN: clang -o %t1 %t-dis.ll -mx32 // RUN: %t1 2>&1 | FileCheck %s // CHECK: PASS: 1-d BSS Initialization // CHECK: PASS: 1-d Initialization // CHECK: PASS: 2-d BSS Initialization // CHECK: PASS: 2-d Initialization // CHECK: Arr_2_Glob[10][12] = 10000 #include <stdio.h> #define ARRAY_SIZE 50 #define ITER_COUNT 10000 int incr(int arr[ARRAY_SIZE][ARRAY_SIZE]) { arr[10][12] += 1; return 0; } int Arr_1_Glob[ARRAY_SIZE]; int Arr_2_Glob[ARRAY_SIZE][ARRAY_SIZE]; int main(int argc, char **argv) { Arr_1_Glob[8] = 42; Arr_2_Glob[8][7] = 4242; if (Arr_1_Glob[0] == 0) { printf("PASS: 1-d BSS Initialization\n"); } else { printf("FAIL: 1-d BSS Initialization\n"); } if (Arr_1_Glob[8] == 42) { printf("PASS: 1-d Initialization\n"); } else { printf("FAIL: 1-d Initialization\n"); } if (Arr_2_Glob[0][0] == 0) { printf("PASS: 2-d BSS Initialization\n"); } else { printf("FAIL: 2-d BSS Initialization\n"); } if (Arr_2_Glob[8][7] == 4242) { printf("PASS: 2-d Initialization\n"); } else { printf("FAIL: 2-d Initialization\n"); } // test global array passed as argument for (int i = 0; i < ITER_COUNT; i++) { incr(Arr_2_Glob); } printf("Arr_2_Glob[10][12] = %d\n", Arr_2_Glob[10][12]); return 0; }
the_stack_data/168937.c
int bcopy(const void *src, void *dest, unsigned int n) { const char *s = (const char *)src; char *d = (char *)dest; if (s <= d) for (; n>0; --n) d[n-1] = s[n-1]; else for (; n>0; --n) *d++ = *s++; } int bzero(void *dest, unsigned int n) { memset(dest, 0, n); } char *memcpy(void *dest, const void *src, unsigned int n) { bcopy(src, dest, n); return dest; } char *memset(void *dest, int c, unsigned int n) { char *d = (char *)dest; for (; n>0; --n) *d++ = (char)c; return dest; } int memcmp(const void *s1, const void *s2, unsigned int n) { const char *s3 = (const char *)s1; const char *s4 = (const char *)s2; for (; n>0; --n) { if (*s3 > *s4) return 1; else if (*s3 < *s4) return -1; ++s3; ++s4; } return 0; } int strcmp(const char *s1, const char *s2) { while ((*s1 && *s2) && (*s1==*s2)){ s1++; s2++; } if (*s1==0 && *s2==0) return 0; return *s1-*s2; } char *strcpy(char *dest, const char *src) { char *p = dest; while ( (*dest++ = *src++)) ; *dest = 0; return p; } int strlen(const char *s) { unsigned int n = 0; while (*s++) ++n; return n; } int strcat(char *s1, char *s2) { while(*s1) s1++; while(*s2) *s1++ = *s2++; *s1 = 0; } int strncpy(char *s1, char *s2, int n) { char *p = s1; while(n && *s2){ *s1++ = *s2++; n--; } *s1 = 0; return (int)p; } int strncmp(char *s1, char *s2, int n) { if (n==0) return 0; do{ if (*s1 != *s2++) return *s1-*(s2-1); if (*s1++ == 0) break; } while(--n != 0); return 0; } char *strstr(char *s1, char *s2) { /* s1="....abc...", s2="abc" ==> find first occurrence of "abc" */ int i, len; len = strlen(s2); for (i=0; i<strlen(s1)-strlen(s2); i++){ if (strncmp(&s1[i], s2, len)==0) return &s1[i]; } return 0; } int setzero(char *dst, int size) { int i; for (i=0; i<size; i++) *dst++ = 0; } void delay() { int i; for (i=0; i<10000; i++); } int copy(char *dest, char *src) { int i; for (i=0; i<1024; i++) *dest++ = *src++; } int atoi(char *s) { int v = 0; while(*s){ v = 10*v + (*s - '0'); s++; } return v; } char *strtok(char *s, char *delim) { static char *p = 0; char *q; if (s) p = s; if (!p) return 0; while (*p && strchr(delim, *p)) p++; if (!*p) return 0; q = p; while (*p && !strchr(delim, *p)) p++; if (*p) *p++ = 0; return q; } // Like strstr but for char. char *strchr(char *s, char c) { while (*s) if (*s++ == c) return s-1; return 0; }
the_stack_data/100141433.c
#define DEV_PATH_NAME_LEN 16 #define FILE_PATH_NAME_LEN 3 #ifndef QEMU #define FILE_RECT_START_X 10 #define FILE_RECT_START_Y 20 #else #define FILE_RECT_START_X 90 #define FILE_RECT_START_Y 80 #endif /* QEMU */ #define RECT_WIDTH_PER_CH 12 #define FILE_RECT_HEIGHT 20 #define FILE_MARGIN_WIDTH 7 #define WAIT_MOUSE_POLL 100000 #define NULL (void *)0 #define TRUE 1 #define FALSE 0 #define EFIERR(a) (0x8000000000000000 | a) #define EFI_SUCCESS 0 #define EFI_INVALID_PARAMETER EFIERR(2) #define EFI_DEVICE_ERROR EFIERR(7) //******************************************************* // Open Modes //******************************************************* #define EFI_FILE_MODE_READ 0x0000000000000001 #define EFI_FILE_MODE_WRITE 0x0000000000000002 #define EFI_FILE_MODE_CREATE 0x8000000000000000 //******************************************************* // File Attributes //******************************************************* #define EFI_FILE_READ_ONLY 0x0000000000000001 #define EFI_FILE_HIDDEN 0x0000000000000002 #define EFI_FILE_SYSTEM 0x0000000000000004 #define EFI_FILE_RESERVED 0x0000000000000008 #define EFI_FILE_DIRECTORY 0x0000000000000010 #define EFI_FILE_ARCHIVE 0x0000000000000020 #define EFI_FILE_VALID_ATTR 0x0000000000000037 #define EVT_TIMER 0x80000000 #define EVT_RUNTIME 0x40000000 #define EVT_NOTIFY_WAIT 0x00000100 #define EVT_NOTIFY_SIGNAL 0x00000200 #define EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201 #define EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202 #define MEDIA_DEVICE_PATH 0x04 #define MEDIA_FILEPATH_DP 0x04 #define END_DEVICE_PATH_TYPE 0x7f #define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff #define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 #define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002 #define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004 #define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008 #define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010 #define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020 struct EFI_INPUT_KEY { unsigned short ScanCode; unsigned short UnicodeChar; }; struct EFI_GUID { unsigned int Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; }; struct EFI_DEVICE_PATH_PROTOCOL { unsigned char Type; unsigned char SubType; unsigned char Length[2]; }; enum EFI_TIMER_DELAY { TimerCancel, TimerPeriodic, TimerRelative }; //******************************************************* //EFI_MEMORY_TYPE //******************************************************* // These type values are discussed in Table 24 and Table 25. enum EFI_MEMORY_TYPE { EfiReservedMemoryType, EfiLoaderCode, EfiLoaderData, EfiBootServicesCode, EfiBootServicesData, EfiRuntimeServicesCode, EfiRuntimeServicesData, EfiConventionalMemory, EfiUnusableMemory, EfiACPIReclaimMemory, EfiACPIMemoryNVS, EfiMemoryMappedIO, EfiMemoryMappedIOPortSpace, EfiPalCode, EfiMaxMemoryType }; struct EFI_SYSTEM_TABLE { char _buf1[44]; struct EFI_SIMPLE_TEXT_INPUT_PROTOCOL { void *_buf; unsigned long long (*ReadKeyStroke)(struct EFI_SIMPLE_TEXT_INPUT_PROTOCOL *, struct EFI_INPUT_KEY *); } *ConIn; void *_buf2; struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL { void *_buf; unsigned long long (*OutputString)(struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *, unsigned short *); char _buf2[32]; unsigned long long (*ClearScreen)(struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *); } *ConOut; char _buf3[24]; struct EFI_BOOT_SERVICES { char _buf1[24]; // // Task Priority Services // unsigned long long _buf2[2]; // // Memory Services // unsigned long long _buf3[3]; unsigned long long (*AllocatePool)( enum EFI_MEMORY_TYPE PoolType, unsigned long long Size, void **Buffer); unsigned long long (*FreePool)( void **Buffer); // // Event & Timer Services // unsigned long long (*CreateEvent)( unsigned int Type, unsigned long long NotifyTpl, void (*NotifyFunction)(void *Event, void *Context), void *NotifyContext, void *Event); unsigned long long (*SetTimer)(void *Event, enum EFI_TIMER_DELAY Type, unsigned long long TriggerTime); unsigned long long (*WaitForEvent)( unsigned long long NumberOfEvents, void *Event, unsigned long long *Index); unsigned long long _buf4[3]; // // Protocol Handler Services // unsigned long long _buf5[3]; unsigned long long (*HandleProtocol)( void *Handle, struct EFI_GUID *Protocol, void **Interface); unsigned long long _buf5_2[5]; // // Image Services // unsigned long long (*LoadImage)( unsigned char BootPolicy, void *ParentImageHandle, struct EFI_DEVICE_PATH_PROTOCOL *DevicePath, void *SourceBuffer, unsigned long long SourceSize, void **ImageHandle); unsigned long long (*StartImage)( void *ImageHandle, unsigned long long *ExitDataSize, unsigned short **ExitData); unsigned long long _buf6[3]; // // Miscellaneous Services // unsigned long long _buf7[2]; unsigned long long (*SetWatchdogTimer)( unsigned long long Timeout, unsigned long long WatchdogCode, unsigned long long DataSize, unsigned short *WatchdogData); // // DriverSupport Services // unsigned long long _buf8[2]; // // Open and Close Protocol Services // unsigned long long (*OpenProtocol)( void *Handle, struct EFI_GUID *Protocol, void **Interface, void *AgentHandle, void *ControllerHandle, unsigned int Attributes); unsigned long long _buf9[2]; // // Library Services // unsigned long long _buf10[2]; unsigned long long (*LocateProtocol)(struct EFI_GUID *, void *, void **); unsigned long long _buf11[2]; // // 32-bit CRC Services // unsigned long long _buf12; // // Miscellaneous Services // unsigned long long _buf13[3]; } *BootServices; }; struct EFI_SIMPLE_POINTER_STATE { int RelativeMovementX; int RelativeMovementY; int RelativeMovementZ; unsigned char LeftButton; unsigned char RightButton; }; struct EFI_SIMPLE_POINTER_MODE { unsigned long long ResolutionX; unsigned long long ResolutionY; unsigned long long ResolutionZ; unsigned char LeftButton; unsigned char RightButton; }; struct EFI_SIMPLE_POINTER_PROTOCOL { unsigned long long (*Reset)( struct EFI_SIMPLE_POINTER_PROTOCOL *This, unsigned char ExtendedVerification); unsigned long long (*GetState)( struct EFI_SIMPLE_POINTER_PROTOCOL *This, struct EFI_SIMPLE_POINTER_STATE *State); void *WaitForInput; struct EFI_SIMPLE_POINTER_MODE *Mode; }; struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL { unsigned char Blue; unsigned char Green; unsigned char Red; unsigned char Reserved; }; enum EFI_GRAPHICS_OUTPUT_BLT_OPERATION { EfiBltVideoFill, EfiBltVideoToBltBuffer, EfiBltBufferToVideo, EfiBltVideoToVideo, EfiGraphicsOutputBltOperationMax }; enum EFI_GRAPHICS_PIXEL_FORMAT { PixelRedGreenBlueReserved8BitPerColor, PixelBlueGreenRedReserved8BitPerColor, PixelBitMask, PixelBltOnly, PixelFormatMax }; //******************************************************* //EFI_TIME //******************************************************* // This represents the current time information struct EFI_TIME { unsigned short Year; // 1900 – 9999 unsigned char Month; // 1 – 12 unsigned char Day; // 1 – 31 unsigned char Hour; // 0 – 23 unsigned char Minute; // 0 – 59 unsigned char Second; // 0 – 59 unsigned char Pad1; unsigned int Nanosecond; // 0 – 999,999,999 unsigned short TimeZone; // -1440 to 1440 or 2047 unsigned char Daylight; unsigned char Pad2; }; struct EFI_FILE_INFO { unsigned long long Size; unsigned long long FileSize; unsigned long long PhysicalSize; struct EFI_TIME CreateTime; struct EFI_TIME LastAccessTime; struct EFI_TIME ModificationTime; unsigned long long Attribute; unsigned short FileName[]; }; struct EFI_GRAPHICS_OUTPUT_PROTOCOL { void *_buf; unsigned long long (*SetMode)(struct EFI_GRAPHICS_OUTPUT_PROTOCOL *, unsigned int); unsigned long long (*Blt)(struct EFI_GRAPHICS_OUTPUT_PROTOCOL *, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *, enum EFI_GRAPHICS_OUTPUT_BLT_OPERATION, unsigned long long SourceX, unsigned long long SourceY, unsigned long long DestinationX, unsigned long long DestinationY, unsigned long long Width, unsigned long long Height, unsigned long long Delta); struct EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE { unsigned int MaxMode; unsigned int Mode; struct EFI_GRAPHICS_OUTPUT_MODE_INFORMATION { unsigned int Version; unsigned int HorizontalResolution; unsigned int VerticalResolution; enum EFI_GRAPHICS_PIXEL_FORMAT PixelFormat; struct EFI_PIXEL_BITMASK { unsigned int RedMask; unsigned int GreenMask; unsigned int BlueMask; unsigned int ReservedMask; } PixelInformation; unsigned int PixelsPerScanLine; } *Info; unsigned long long SizeOfInfo; unsigned long long FrameBufferBase; unsigned long long FrameBufferSize; } *Mode; }; struct EFI_FILE_PROTOCOL { unsigned long long Revision; unsigned long long (*Open)(struct EFI_FILE_PROTOCOL *This, struct EFI_FILE_PROTOCOL **NewHandle, unsigned short *FileName, unsigned long long OpenMode, unsigned long long Attributes); unsigned long long (*Close)(struct EFI_FILE_PROTOCOL *This); unsigned long long (*Delete)(struct EFI_FILE_PROTOCOL *This); unsigned long long (*Read)(struct EFI_FILE_PROTOCOL *This, unsigned long long *BufferSize, void *Buffer); unsigned long long (*Write)(struct EFI_FILE_PROTOCOL *This, unsigned long long *BufferSize, void *Buffer); unsigned long long (*GetPosition)(struct EFI_FILE_PROTOCOL *This, unsigned long long *Position); unsigned long long (*SetPosition)(struct EFI_FILE_PROTOCOL *This, unsigned long long Position); unsigned long long (*GetInfo)(struct EFI_FILE_PROTOCOL *This, struct EFI_GUID *InformationType, unsigned long long *BufferSize, void *Buffer); unsigned long long (*SetInfo)(struct EFI_FILE_PROTOCOL *This, struct EFI_GUID *InformationType, unsigned long long BufferSize, void *Buffer); unsigned long long (*Flush)(struct EFI_FILE_PROTOCOL *This); }; struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL { unsigned long long Revision; unsigned long long (*OpenVolume)( struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *This, struct EFI_FILE_PROTOCOL **Root); }; struct EFI_LOADED_IMAGE_PROTOCOL { unsigned int Revision; void *ParentHandle; struct EFI_SYSTEM_TABLE *SystemTable; // Source location of the image void *DeviceHandle; struct EFI_DEVICE_PATH_PROTOCOL *FilePath; void *Reserved; // Image’s load options unsigned int LoadOptionsSize; void *LoadOptions; // Location where image was loaded void *ImageBase; unsigned long long ImageSize; enum EFI_MEMORY_TYPE ImageCodeType; enum EFI_MEMORY_TYPE ImageDataType; unsigned long long (*Unload)(void *ImageHandle); }; struct EFI_CPU_PHYSICAL_LOCATION { unsigned int Package; unsigned int Core; unsigned int Thread; }; struct EFI_PROCESSOR_INFORMATION { unsigned long long ProcessorId; unsigned int StatusFlag; struct EFI_CPU_PHYSICAL_LOCATION Location; }; struct EFI_MP_SERVICES_PROTOCOL { unsigned long long (*GetNumberOfProcessors)( struct EFI_MP_SERVICES_PROTOCOL *This, unsigned long long *NumberOfProcessors, unsigned long long *NumberOfEnabledProcessors); unsigned long long (*GetProcessorInfo)( struct EFI_MP_SERVICES_PROTOCOL *This, unsigned long long ProcessorNumber, struct EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer); unsigned long long (*StartupAllAPs)( struct EFI_MP_SERVICES_PROTOCOL *This, void (*Procedure)(void *ProcedureArgument), unsigned char SingleThread, void *WaitEvent, unsigned long long TimeoutInMicroSeconds, void *ProcedureArgument, unsigned long long **FailedCpuList); unsigned long long (*StartupThisAP)( struct EFI_MP_SERVICES_PROTOCOL *This, void (*Procedure)(void *ProcedureArgument), unsigned long long ProcessorNumber, void *WaitEvent, unsigned long long TimeoutInMicroseconds, void *ProcedureArgument, unsigned char *Finished); unsigned long long (*SwitchBSP)( struct EFI_MP_SERVICES_PROTOCOL *This, unsigned long long ProcessorNumber, unsigned char EnableOldBSP); unsigned long long (*EnableDisableAP)( struct EFI_MP_SERVICES_PROTOCOL *This, unsigned long long ProcessorNumber, unsigned char EnableAP, unsigned int *HealthFlag); unsigned long long (*WhoAmI)( struct EFI_MP_SERVICES_PROTOCOL *This, unsigned long long *ProcessorNumber); }; struct LIST { struct LIST *next; struct LIST *prev; }; struct RECT { unsigned int x; unsigned int y; unsigned int width; unsigned int height; }; struct FILE_LIST { struct LIST list; struct RECT rect; unsigned int size; unsigned short name[]; }; void *IH; struct EFI_SYSTEM_TABLE *ST; struct EFI_GRAPHICS_OUTPUT_PROTOCOL *GOP; struct EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SFSP; struct EFI_SIMPLE_POINTER_PROTOCOL *SPP; struct LIST FILE_LIST_HEAD; unsigned short BUF_STR[1024]; unsigned long long strlen(const unsigned short str[]) { unsigned long long i = 0; while (str[i++]); return i; } void memcpy(unsigned char *dst, unsigned char *src, unsigned long long size) { while (size--) *dst++ = *src++; } unsigned short *int_to_unicode(long long val, unsigned char num_digits, unsigned short str[]) { unsigned char digits_base = 0; char i; if (val < 0) { str[digits_base++] = L'-'; val *= -1; } for (i = num_digits - 1; i >= 0; i--) { str[digits_base + i] = L'0' + (val % 10); val /= 10; } str[digits_base + num_digits] = L'\0'; return str; } unsigned short *int_to_unicode_hex(unsigned long long val, unsigned char num_digits, unsigned short str[]) { short i; unsigned short v; for (i = num_digits - 1; i >= 0; i--) { v = (unsigned short)(val & 0x0f); if (v < 0xa) str[i] = L'0' + v; else str[i] = L'A' + (v - 0xa); val >>= 4; } str[num_digits] = L'\0'; return str; } unsigned short *ascii_to_unicode(char ascii[], unsigned char num_digits, unsigned short str[]) { unsigned char i; for (i = 0; i < num_digits; i++) { if (ascii[i] == '\0') { break; } if ('0' <= ascii[i] && ascii[i] <= '9') str[i] = L'0' + (ascii[i] - '0'); else if ('A' <= ascii[i] && ascii[i] <= 'Z') str[i] = L'A' + (ascii[i] - 'A'); else if ('a' <= ascii[i] && ascii[i] <= 'z') str[i] = L'a' + (ascii[i] - 'a'); else { switch (ascii[i]) { case ' ': str[i] = L' '; break; case '-': str[i] = L'-'; break; case '+': str[i] = L'+'; break; case '*': str[i] = L'*'; break; case '/': str[i] = L'/'; break; case '&': str[i] = L'&'; break; case '|': str[i] = L'|'; break; case '%': str[i] = L'%'; break; case '#': str[i] = L'#'; break; case '!': str[i] = L'!'; break; case '\r': str[i] = L'\r'; break; case '\n': str[i] = L'\n'; break; } } } str[i] = L'\0'; return str; } volatile unsigned char lock_conout = 0; void puts(unsigned short *str, struct EFI_SYSTEM_TABLE *SystemTable) { while (lock_conout); lock_conout = 1; SystemTable->ConOut->OutputString(SystemTable->ConOut, str); lock_conout = 0; } void check_status(unsigned long long status, unsigned short *name, struct EFI_SYSTEM_TABLE *SystemTable) { unsigned short str[34]; if (status) { puts(L"error: ", SystemTable); puts(name, SystemTable); puts(L": ", SystemTable); puts(int_to_unicode_hex(status, 16, str), SystemTable); puts(L"\r\n", SystemTable); while (1); } } void queue_init(struct LIST *head) { head->next = head; head->prev = head; } void queue_enq(struct LIST *entry, struct LIST *head) { entry->prev = head->prev; entry->next = head; head->prev->next = entry; head->prev = entry; } void draw_pixel(unsigned int x, unsigned int y, struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color, struct EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) { unsigned int hr = gop->Mode->Info->HorizontalResolution; struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)gop->Mode->FrameBufferBase; struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; p->Blue = color.Blue; p->Green = color.Green; p->Red = color.Red; p->Reserved = color.Reserved; } struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL get_pixel(unsigned int x, unsigned int y) { unsigned int hr = GOP->Mode->Info->HorizontalResolution; struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *base = (struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)GOP->Mode->FrameBufferBase; struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL *p = base + (hr * y) + x; return *p; } void draw_rect(unsigned int x, unsigned int y, unsigned int w, unsigned int h, struct EFI_GRAPHICS_OUTPUT_PROTOCOL *gop) { unsigned int i; struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {0xff, 0xff, 0xff, 0xff}; for (i = x; i < (x + w); i++) draw_pixel(i, y, color, gop); for (i = x; i < (x + w); i++) draw_pixel(i, y + h - 1, color, gop); for (i = y; i < (y + h); i++) draw_pixel(x, i, color, gop); for (i = y; i < (y + h); i++) draw_pixel(x + w - 1, i, color, gop); } void init_protocols(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) { unsigned long long status; struct EFI_GUID gop_guid = {0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a}}; struct EFI_GUID sfsp_guid = {0x0964e5b22, 0x6459,0x11d2, {0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b}}; struct EFI_GUID spp_guid = {0x31878c87, 0xb75, 0x11d5, {0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d}}; IH = ImageHandle; ST = SystemTable; status = SystemTable->BootServices->LocateProtocol(&gop_guid, NULL, (void **)&GOP); check_status(status, L"LocateProtocol(GOP)", ST); status = SystemTable->BootServices->LocateProtocol(&sfsp_guid, NULL, (void **)&SFSP); check_status(status, L"LocateProtocol(SFSP)", ST); status = SystemTable->BootServices->LocateProtocol(&spp_guid, NULL, (void **)&SPP); check_status(status, L"LocateProtocol(SPP)", ST); } #define MAX_FILE_BUF 1024 void draw_file_list(void) { unsigned long long status; struct EFI_FILE_PROTOCOL *root; unsigned long long buf_size = MAX_FILE_BUF; char file_buf[MAX_FILE_BUF]; status = SFSP->OpenVolume(SFSP, &root); check_status(status, L"OpenVolume", ST); struct EFI_FILE_INFO *efi; unsigned long long file_name_size; unsigned long long file_entry_size; struct FILE_LIST *file_entry; while (buf_size) { buf_size = MAX_FILE_BUF; status = root->Read(root, &buf_size, (void *)file_buf); check_status(status, L"Read", ST); if (buf_size) { efi = (struct EFI_FILE_INFO *)file_buf; file_name_size = efi->Size - sizeof(struct EFI_FILE_INFO); file_entry_size = sizeof(struct FILE_LIST) + file_name_size; status = ST->BootServices->AllocatePool( EfiBootServicesData, file_entry_size, (void **)&file_entry); check_status(status, L"AllocatePool", ST); file_entry->size = file_entry_size; memcpy((unsigned char *)file_entry->name, (unsigned char *)efi->FileName, file_name_size); queue_enq((struct LIST *)file_entry, &FILE_LIST_HEAD); } } ST->ConOut->ClearScreen(ST->ConOut); puts(L"\r\n", ST); for (file_entry = (struct FILE_LIST *)FILE_LIST_HEAD.next; FILE_LIST_HEAD.next != &FILE_LIST_HEAD; file_entry = (struct FILE_LIST *)file_entry->list.next) { puts(L" ", ST); puts(file_entry->name, ST); if (file_entry->list.next == &FILE_LIST_HEAD) break; } unsigned int start_x = FILE_RECT_START_X; unsigned int start_y = FILE_RECT_START_Y; unsigned int file_rect_width; for (file_entry = (struct FILE_LIST *)FILE_LIST_HEAD.next; FILE_LIST_HEAD.next != &FILE_LIST_HEAD; file_entry = (struct FILE_LIST *)file_entry->list.next) { file_rect_width = ((unsigned int)strlen(file_entry->name) - 1) * RECT_WIDTH_PER_CH; file_entry->rect.x = start_x; file_entry->rect.y = start_y; file_entry->rect.width = file_rect_width; file_entry->rect.height = FILE_RECT_HEIGHT; draw_rect(file_entry->rect.x, file_entry->rect.y, file_entry->rect.width, file_entry->rect.height, GOP); start_x += file_rect_width + FILE_MARGIN_WIDTH; if (file_entry->list.next == &FILE_LIST_HEAD) break; } status = root->Close(root); check_status(status, L"Close", ST); } void poll_mouse_pointer(void) { unsigned long long status; struct EFI_SIMPLE_POINTER_STATE sps; int x = 0; int y = 0; unsigned char is_first = 1; struct EFI_GRAPHICS_OUTPUT_BLT_PIXEL tmp[4]; status = SPP->Reset(SPP, FALSE); check_status(status, L"Reset(SPP)", ST); while (1) { status = SPP->GetState(SPP, &sps); if (!status) { if (!is_first) { draw_pixel(x, y, tmp[0], GOP); draw_pixel(x + 1, y, tmp[1], GOP); draw_pixel(x, y + 1, tmp[2], GOP); draw_pixel(x + 1, y + 1, tmp[3], GOP); } else { is_first = 0; } x += sps.RelativeMovementX >> 13; if (x < 0) x = 0; y += sps.RelativeMovementY >> 13; if (y < 0) y = 0; tmp[0] = get_pixel(x, y); tmp[1] = get_pixel(x + 1, y); tmp[2] = get_pixel(x, y + 1); tmp[3] = get_pixel(x + 1, y + 1); draw_rect(x, y, 2, 2, GOP); } } } void efi_main(void *ImageHandle, struct EFI_SYSTEM_TABLE *SystemTable) { init_protocols(ImageHandle, SystemTable); queue_init(&FILE_LIST_HEAD); draw_file_list(); poll_mouse_pointer(); while (1); }
the_stack_data/59904.c
#include<stdio.h> void main() { float c; printf("Enter temperature in celsius: "); scanf("%f", &c); printf("%f ° C => %f ° F", c, c * 1.8 + 32); }
the_stack_data/95451577.c
#include <stdio.h> int myage = 43; // int variable int* ptr = &myage; // poiter variable store addr of myage void main() { printf("%d\n", myage); printf("%p\n", &myage); printf("%p\n", ptr); // Use deference printf("%d\n", *ptr); }
the_stack_data/1803.c
#include <stdio.h> #include <stdlib.h> #include <locale.h> int main(){ //Aluno: Elvis Rodrigues Almeida int numeros[4], i, ii, cont1=0, cont2=0; setlocale(LC_ALL, "Portuguese"); system("cls"); //Entrada de dados printf("Digite o valor da variavel A: "); scanf("%d", &numeros[0]); printf("Digite o valor da variavel B: "); scanf("%d", &numeros[1]); printf("Digite o valor da variavel C: "); scanf("%d", &numeros[2]); printf("Digite o valor da variavel D: "); scanf("%d", &numeros[3]); //printf("%d %d %d %d\n", numeros[0], numeros[1], numeros[2], numeros[3]); //Processamento cont2 = 0; for (ii = 0; ii < 4; ii++) { for (i = 0; i < 4; i++) { if (cont1 != cont2) { if (cont1 < cont2) { //saída //printf("%d , %d", cont1, cont2); printf("\n%d + %d = %d", numeros[cont1], numeros[cont2], numeros[cont1] + numeros[cont2]); printf("\n%d x %d = %d\n", numeros[cont1], numeros[cont2], numeros[cont1] * numeros[cont2]); } } cont2++; } cont2 = 0; cont1++; } system("pause"); }
the_stack_data/17788.c
// // msg_rmid.c // LearnSocket // // Created by Zhang Yuanming on 3/24/18. // Copyright © 2018 HansonStudio. All rights reserved. // #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #define ERR_EXIT(m) \ do \ { \ perror(m); \ exit(EXIT_FAILURE); \ } while(0) int main(void) { int msgid; // 打开消息队列 msgid = msgget(1234, 0); if (msgid == -1) { ERR_EXIT("msgget"); } printf("msgget succ\n"); printf("msgid=%d\n", msgid); // 删除消息队列 msgctl(msgid, IPC_RMID, NULL); return 0; }
the_stack_data/637274.c
/*BEGIN_LEGAL Intel Open Source License Copyright (c) 2002-2016 Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. END_LEGAL */ // Verify that Pin does not crash if the application terminates with a // fatal synchronous signal. int main() { int *p = (int *)0x9; *p = 8; return 0; }
the_stack_data/1069215.c
/* Copyright (c) 2016 Hubert Denkmair <[email protected]> This file is part of the candle windows API. This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>. */ #ifdef _WIN32 #include "candle.h" #include <stdlib.h> #include "candle_defs.h" #include "candle_ctrl_req.h" #include "ch_9.h" #pragma comment(lib, "winusb.lib") #pragma comment(lib, "setupapi.lib") #pragma comment(lib, "ole32.lib") #undef DLL #define DLL static bool candle_read_device_name(HDEVINFO hdi, SP_DEVINFO_DATA* spDevInfoData, candle_device_t* dev) { DWORD DataT; DWORD nSize = 0; dev->name[0] = '\0'; if (SetupDiGetDeviceRegistryProperty(hdi, spDevInfoData, SPDRP_FRIENDLYNAME, &DataT, (PBYTE)dev->name, sizeof(dev->name) / sizeof(dev->name[0]), &nSize)) { return true; } else { #ifdef UNICODE swprintf(dev->name, sizeof(dev->name) / sizeof(dev->name[0]), L"Error: Failed to read name"); #else snprintf(dev->name, sizeof(dev->name) / sizeof(dev->name[0]), "Error: Failed to read name"); #endif return false; } } static bool candle_dev_interal_open(candle_handle hdev); static bool candle_read_di(HDEVINFO hdi, SP_DEVICE_INTERFACE_DATA interfaceData, candle_device_t *dev) { /* get required length first (this call always fails with an error) */ ULONG requiredLength=0; SetupDiGetDeviceInterfaceDetail(hdi, &interfaceData, NULL, 0, &requiredLength, NULL); if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) { dev->last_error = CANDLE_ERR_SETUPDI_IF_DETAILS; return false; } PSP_DEVICE_INTERFACE_DETAIL_DATA detail_data = (PSP_DEVICE_INTERFACE_DETAIL_DATA) LocalAlloc(LMEM_FIXED, requiredLength); if (detail_data != NULL) { detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); } else { dev->last_error = CANDLE_ERR_MALLOC; return false; } bool retval = true; ULONG length = requiredLength; if (!SetupDiGetDeviceInterfaceDetail(hdi, &interfaceData, detail_data, length, &requiredLength, NULL) ) { dev->last_error = CANDLE_ERR_SETUPDI_IF_DETAILS2; retval = false; } else if (FAILED(StringCchCopy(dev->path, sizeof(dev->path) / sizeof(dev->path[0]), detail_data->DevicePath))) { dev->last_error = CANDLE_ERR_PATH_LEN; retval = false; } LocalFree(detail_data); if (!retval) { return false; } /* try to open to read device infos and see if it is avail */ if (candle_dev_interal_open(dev)) { dev->state = CANDLE_DEVSTATE_AVAIL; candle_dev_close(dev); } else { dev->state = CANDLE_DEVSTATE_INUSE; } dev->last_error = CANDLE_ERR_OK; return true; } bool __cdecl candle_list_scan(candle_list_handle *list) { if (list==NULL) { return false; } candle_list_t *l = (candle_list_t *)calloc(1, sizeof(candle_list_t)); *list = l; if (l==NULL) { return false; } GUID guid; if (CLSIDFromString(L"{c15b4308-04d3-11e6-b3ea-6057189e6443}", &guid) != NOERROR) { l->last_error = CANDLE_ERR_CLSID; return false; } HDEVINFO hdi = SetupDiGetClassDevs(&guid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (hdi == INVALID_HANDLE_VALUE) { l->last_error = CANDLE_ERR_GET_DEVICES; return false; } bool rv = false; for (unsigned i=0; i<CANDLE_MAX_DEVICES; i++) { SP_DEVICE_INTERFACE_DATA interfaceData; interfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); if (SetupDiEnumDeviceInterfaces(hdi, NULL, &guid, i, &interfaceData)) { if (!candle_read_di(hdi, interfaceData, &l->dev[i])) { l->last_error = l->dev[i].last_error; rv = false; break; } } else { DWORD err = GetLastError(); if (err==ERROR_NO_MORE_ITEMS) { l->num_devices = i; l->last_error = CANDLE_ERR_OK; rv = true; } else { l->last_error = CANDLE_ERR_SETUPDI_IF_ENUM; rv = false; } break; } SP_DEVINFO_DATA devInfoData; devInfoData.cbSize = sizeof(SP_DEVINFO_DATA); if (SetupDiEnumDeviceInfo(hdi, i, &devInfoData)) { candle_read_device_name(hdi, &devInfoData, &l->dev[i]); } else { #ifdef UNICODE swprintf(l->dev[i].name, sizeof(l->dev[i].name) / sizeof(l->dev[i].name[0]), L"Unknown"); #else snprintf(l->dev[i].name, sizeof(l->dev[i].name) / sizeof(l->dev[i].name[0]), "Unknown"); #endif } } SetupDiDestroyDeviceInfoList(hdi); return rv; } candle_err_t __cdecl DLL candle_list_last_error(candle_list_handle list) { candle_list_t* dev = (candle_list_t*)list; return dev->last_error; } bool __cdecl DLL candle_list_free(candle_list_handle list) { free(list); return true; } bool __cdecl DLL candle_list_length(candle_list_handle list, uint8_t *len) { candle_list_t *l = (candle_list_t *)list; *len = l->num_devices; return true; } bool __cdecl DLL candle_dev_get(candle_list_handle list, uint8_t dev_num, candle_handle *hdev) { candle_list_t *l = (candle_list_t *)list; if (l==NULL) { return false; } if (dev_num >= CANDLE_MAX_DEVICES) { l->last_error = CANDLE_ERR_DEV_OUT_OF_RANGE; return false; } candle_device_t *dev = calloc(1, sizeof(candle_device_t)); *hdev = dev; if (dev==NULL) { l->last_error = CANDLE_ERR_MALLOC; return false; } memcpy(dev, &l->dev[dev_num], sizeof(candle_device_t)); l->last_error = CANDLE_ERR_OK; dev->last_error = CANDLE_ERR_OK; return true; } bool __cdecl DLL candle_dev_get_state(candle_handle hdev, candle_devstate_t *state) { if (hdev==NULL) { return false; } else { candle_device_t *dev = (candle_device_t*)hdev; *state = dev->state; return true; } } #ifdef UNICODE wchar_t* __cdecl DLL candle_dev_get_path(candle_handle hdev) #else char* __cdecl DLL candle_dev_get_path(candle_handle hdev) #endif { if (hdev==NULL) { return NULL; } else { candle_device_t *dev = (candle_device_t*)hdev; return dev->path; } } #ifdef UNICODE wchar_t* __cdecl DLL candle_dev_get_name(candle_handle hdev) #else char* __cdecl DLL candle_dev_get_name(candle_handle hdev) #endif { if (hdev == NULL) { return NULL; } else { candle_device_t* dev = (candle_device_t*)hdev; return dev->name; } } static bool candle_dev_interal_open(candle_handle hdev) { candle_device_t *dev = (candle_device_t*)hdev; memset(dev->rxevents, 0, sizeof(dev->rxevents)); memset(dev->rxurbs, 0, sizeof(dev->rxurbs)); dev->deviceHandle = CreateFile( dev->path, GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL ); if (dev->deviceHandle == INVALID_HANDLE_VALUE) { dev->last_error = CANDLE_ERR_CREATE_FILE; return false; } if (!WinUsb_Initialize(dev->deviceHandle, &dev->winUSBHandle)) { dev->last_error = CANDLE_ERR_WINUSB_INITIALIZE; goto close_handle; } USB_INTERFACE_DESCRIPTOR ifaceDescriptor; if (!WinUsb_QueryInterfaceSettings(dev->winUSBHandle, 0, &ifaceDescriptor)) { dev->last_error = CANDLE_ERR_QUERY_INTERFACE; goto winusb_free; } dev->interfaceNumber = ifaceDescriptor.bInterfaceNumber; unsigned pipes_found = 0; for (uint8_t i=0; i<ifaceDescriptor.bNumEndpoints; i++) { WINUSB_PIPE_INFORMATION pipeInfo; if (!WinUsb_QueryPipe(dev->winUSBHandle, 0, i, &pipeInfo)) { dev->last_error = CANDLE_ERR_QUERY_PIPE; goto winusb_free; } if (pipeInfo.PipeType == UsbdPipeTypeBulk && USB_ENDPOINT_DIRECTION_IN(pipeInfo.PipeId)) { dev->bulkInPipe = pipeInfo.PipeId; pipes_found++; } else if (pipeInfo.PipeType == UsbdPipeTypeBulk && USB_ENDPOINT_DIRECTION_OUT(pipeInfo.PipeId)) { dev->bulkOutPipe = pipeInfo.PipeId; pipes_found++; } else { dev->last_error = CANDLE_ERR_PARSE_IF_DESCR; goto winusb_free; } } if (pipes_found != 2) { dev->last_error = CANDLE_ERR_PARSE_IF_DESCR; goto winusb_free; } char use_raw_io = 1; if (!WinUsb_SetPipePolicy(dev->winUSBHandle, dev->bulkInPipe, RAW_IO, sizeof(use_raw_io), &use_raw_io)) { dev->last_error = CANDLE_ERR_SET_PIPE_RAW_IO; goto winusb_free; } if (!candle_ctrl_set_host_format(dev)) { goto winusb_free; } if (!candle_ctrl_get_config(dev, &dev->dconf)) { goto winusb_free; } if (!candle_ctrl_get_capability(dev, 0, &dev->bt_const)) { dev->last_error = CANDLE_ERR_GET_BITTIMING_CONST; goto winusb_free; } dev->last_error = CANDLE_ERR_OK; return true; winusb_free: WinUsb_Free(dev->winUSBHandle); close_handle: CloseHandle(dev->deviceHandle); return false; } static bool candle_prepare_read(candle_device_t *dev, unsigned urb_num) { bool rc = WinUsb_ReadPipe( dev->winUSBHandle, dev->bulkInPipe, dev->rxurbs[urb_num].buf, sizeof(dev->rxurbs[urb_num].buf), NULL, &dev->rxurbs[urb_num].ovl ); if (rc || (GetLastError()!=ERROR_IO_PENDING)) { dev->last_error = CANDLE_ERR_PREPARE_READ; return false; } else { dev->last_error = CANDLE_ERR_OK; return true; } } static bool candle_close_rxurbs(candle_device_t *dev) { for (unsigned i=0; i<CANDLE_URB_COUNT; i++) { if (dev->rxevents[i] != NULL) { CloseHandle(dev->rxevents[i]); } } return true; } bool __cdecl DLL candle_dev_open(candle_handle hdev) { candle_device_t *dev = (candle_device_t*)hdev; if (candle_dev_interal_open(dev)) { for (unsigned i=0; i<CANDLE_URB_COUNT; i++) { HANDLE ev = CreateEvent(NULL, true, false, NULL); dev->rxevents[i] = ev; dev->rxurbs[i].ovl.hEvent = ev; if (!candle_prepare_read(dev, i)) { candle_close_rxurbs(dev); return false; // keep last_error from prepare_read call } } dev->last_error = CANDLE_ERR_OK; return true; } else { return false; // keep last_error from open_device call } } bool __cdecl DLL candle_dev_get_timestamp_us(candle_handle hdev, uint32_t *timestamp_us) { return candle_ctrl_get_timestamp(hdev, timestamp_us); } bool __cdecl DLL candle_dev_close(candle_handle hdev) { candle_device_t *dev = (candle_device_t*)hdev; candle_close_rxurbs(dev); WinUsb_Free(dev->winUSBHandle); dev->winUSBHandle = NULL; CloseHandle(dev->deviceHandle); dev->deviceHandle = NULL; dev->last_error = CANDLE_ERR_OK; return true; } bool __cdecl DLL candle_dev_free(candle_handle hdev) { free(hdev); return true; } candle_err_t __cdecl DLL candle_dev_last_error(candle_handle hdev) { candle_device_t *dev = (candle_device_t*)hdev; return dev->last_error; } bool __cdecl DLL candle_channel_count(candle_handle hdev, uint8_t *num_channels) { // TODO check if info was already read from device; try to do so; throw error... candle_device_t *dev = (candle_device_t*)hdev; *num_channels = dev->dconf.icount+1; return true; } bool __cdecl DLL candle_channel_get_capabilities(candle_handle hdev, uint8_t ch, candle_capability_t *cap) { // TODO check if info was already read from device; try to do so; throw error... candle_device_t *dev = (candle_device_t*)hdev; memcpy(cap, &dev->bt_const.feature, sizeof(candle_capability_t)); return true; } bool __cdecl DLL candle_channel_set_timing(candle_handle hdev, uint8_t ch, candle_bittiming_t *data) { // TODO ensure device is open, check channel count.. candle_device_t *dev = (candle_device_t*)hdev; return candle_ctrl_set_bittiming(dev, ch, data); } bool __cdecl DLL candle_channel_set_bitrate(candle_handle hdev, uint8_t ch, uint32_t bitrate) { // TODO ensure device is open, check channel count.. candle_device_t *dev = (candle_device_t*)hdev; if (dev->bt_const.fclk_can != 48000000) { /* this function only works for the candleLight base clock of 48MHz */ dev->last_error = CANDLE_ERR_BITRATE_FCLK; return false; } candle_bittiming_t t; t.prop_seg = 1; t.sjw = 1; t.phase_seg1 = 13 - t.prop_seg; t.phase_seg2 = 2; switch (bitrate) { case 10000: t.brp = 300; break; case 20000: t.brp = 150; break; case 50000: t.brp = 60; break; case 83333: t.brp = 36; break; case 100000: t.brp = 30; break; case 125000: t.brp = 24; break; case 250000: t.brp = 12; break; case 500000: t.brp = 6; break; case 800000: t.brp = 4; t.phase_seg1 = 12 - t.prop_seg; t.phase_seg2 = 2; break; case 1000000: t.brp = 3; break; default: dev->last_error = CANDLE_ERR_BITRATE_UNSUPPORTED; return false; } return candle_ctrl_set_bittiming(dev, ch, &t); } bool __cdecl DLL candle_channel_start(candle_handle hdev, uint8_t ch, uint32_t flags) { // TODO ensure device is open, check channel count.. candle_device_t *dev = (candle_device_t*)hdev; flags |= CANDLE_MODE_HW_TIMESTAMP; return candle_ctrl_set_device_mode(dev, ch, CANDLE_DEVMODE_START, flags); } bool __cdecl DLL candle_channel_stop(candle_handle hdev, uint8_t ch) { // TODO ensure device is open, check channel count.. candle_device_t *dev = (candle_device_t*)hdev; return candle_ctrl_set_device_mode(dev, ch, CANDLE_DEVMODE_RESET, 0); } bool __cdecl DLL candle_frame_send(candle_handle hdev, uint8_t ch, candle_frame_t *frame) { // TODO ensure device is open, check channel count.. candle_device_t *dev = (candle_device_t*)hdev; unsigned long bytes_sent = 0; frame->echo_id = 0; frame->channel = ch; bool rc = WinUsb_WritePipe( dev->winUSBHandle, dev->bulkOutPipe, (uint8_t*)frame, sizeof(*frame), &bytes_sent, 0 ); dev->last_error = rc ? CANDLE_ERR_OK : CANDLE_ERR_SEND_FRAME; return rc; } bool __cdecl DLL candle_frame_read(candle_handle hdev, candle_frame_t *frame, uint32_t timeout_ms) { // TODO ensure device is open.. candle_device_t *dev = (candle_device_t*)hdev; DWORD wait_result = WaitForMultipleObjects(CANDLE_URB_COUNT, dev->rxevents, false, timeout_ms); if (wait_result == WAIT_TIMEOUT) { dev->last_error = CANDLE_ERR_READ_TIMEOUT; return false; } if ( (wait_result < WAIT_OBJECT_0) || (wait_result >= WAIT_OBJECT_0 + CANDLE_URB_COUNT) ) { dev->last_error = CANDLE_ERR_READ_WAIT; return false; } DWORD urb_num = wait_result - WAIT_OBJECT_0; DWORD bytes_transfered; if (!WinUsb_GetOverlappedResult(dev->winUSBHandle, &dev->rxurbs[urb_num].ovl, &bytes_transfered, false)) { candle_prepare_read(dev, urb_num); dev->last_error = CANDLE_ERR_READ_RESULT; return false; } if (bytes_transfered < sizeof(*frame)-4) { candle_prepare_read(dev, urb_num); dev->last_error = CANDLE_ERR_READ_SIZE; return false; } if (bytes_transfered < sizeof(*frame)) { frame->timestamp_us = 0; } memcpy(frame, dev->rxurbs[urb_num].buf, sizeof(*frame)); return candle_prepare_read(dev, urb_num); } candle_frametype_t __cdecl DLL candle_frame_type(candle_frame_t *frame) { if (frame->echo_id != 0xFFFFFFFF) { return CANDLE_FRAMETYPE_ECHO; }; if (frame->can_id & CANDLE_ID_ERR) { return CANDLE_FRAMETYPE_ERROR; } return CANDLE_FRAMETYPE_RECEIVE; } uint32_t __cdecl DLL candle_frame_id(candle_frame_t *frame) { return frame->can_id & 0x1FFFFFFF; } bool __cdecl DLL candle_frame_is_extended_id(candle_frame_t *frame) { return (frame->can_id & CANDLE_ID_EXTENDED) != 0; } bool __cdecl DLL candle_frame_is_rtr(candle_frame_t *frame) { return (frame->can_id & CANDLE_ID_RTR) != 0; } uint8_t __cdecl DLL candle_frame_dlc(candle_frame_t *frame) { return frame->can_dlc; } uint8_t* __cdecl DLL candle_frame_data(candle_frame_t *frame) { return frame->data; } uint32_t __cdecl DLL candle_frame_timestamp_us(candle_frame_t *frame) { return frame->timestamp_us; } #else void CandleFunc() {} #endif
the_stack_data/497560.c
#include <math.h> #include <stdbool.h> #include <stdlib.h> #include <stdio.h> #include <string.h> int main (int argc, char *argv[]){ int lengthcheck; int i = 0; int prime; int primeparameter; if ( argc < 2 ){ fprintf(stderr, " Please enter 1 integer parameter\n"); exit(-1); } else if ( argc > 2 ){ fprintf(stderr, " Please enter 1 integer parameter\n"); exit(-1); } if ( strlen(argv[1]) > 25 ) { fprintf(stderr, " Please do not try to buffer overflow\n"); exit(-1); } lengthcheck = strlen(argv[1]); for ( i = 0; i < lengthcheck; i++){ if ( isalpha(argv[1][i]) ){ fprintf(stderr, " Please only enter digits \n"); exit(-1); } else if ( isdigit(argv[1][i]) ) { } else { fprintf(stderr," Please only enter digits \n"); exit(-1); } } fprintf(stderr, "This is part 0\n"); fprintf(stderr, "Ivan Capistran\n"); fprintf(stderr, "Parameter: %s\n" ,argv[1]); primeparameter = atoi(argv[1]); prime = isPrimeInt(primeparameter); if (prime){ printf("Is prime\n"); fprintf(stderr, "The answer is prime\n"); } else { printf("Is not prime\n"); fprintf(stderr, "The answer is not prime\n"); } return 0; }
the_stack_data/16400.c
/* * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the * above copyright notice and this permission notice appear in all * copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /* * This file was originally distributed by Qualcomm Atheros, Inc. * under proprietary terms before Copyright ownership was assigned * to the Linux Foundation. */ /****************************************************************************** * wlan_logging_sock_svc.c * ******************************************************************************/ #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE #include <linux/rtc.h> #include <vmalloc.h> #include <wlan_nlink_srv.h> #include <vos_status.h> #include <vos_trace.h> #include <wlan_nlink_common.h> #include <wlan_logging_sock_svc.h> #include <vos_types.h> #include <kthread.h> #include "vos_memory.h" #include <linux/ratelimit.h> #include <asm/arch_timer.h> #include <vos_utils.h> #define LOGGING_TRACE(level, args...) \ VOS_TRACE(VOS_MODULE_ID_SVC, level, ## args) /* Global variables */ #define ANI_NL_MSG_LOG_TYPE 89 #define ANI_NL_MSG_READY_IND_TYPE 90 #define ANI_NL_MSG_LOG_PKT_TYPE 91 #define ANI_NL_MSG_FW_LOG_PKT_TYPE 92 #define INVALID_PID -1 #define MAX_PKTSTATS_LOG_LENGTH 2048 #define MAX_LOGMSG_LENGTH 4096 #define LOGGER_MGMT_DATA_PKT_POST 0x001 #define HOST_LOG_POST 0x002 #define LOGGER_FW_LOG_PKT_POST 0x003 #define LOGGER_FATAL_EVENT_POST 0x004 #define LOGGER_FW_MEM_DUMP_PKT_POST 0x005 #define LOGGER_FW_MEM_DUMP_PKT_POST_DONE 0x006 #define HOST_PKT_STATS_POST 0x008 #define LOGGER_MAX_DATA_MGMT_PKT_Q_LEN (8) #define LOGGER_MAX_FW_LOG_PKT_Q_LEN (16) #define LOGGER_MAX_FW_MEM_DUMP_PKT_Q_LEN (32) #define NL_BDCAST_RATELIMIT_INTERVAL (5*HZ) #define NL_BDCAST_RATELIMIT_BURST 1 #define PTT_MSG_DIAG_CMDS_TYPE 0x5050 #define DIAG_TYPE_LOGS 1 /* Limit FW initiated fatal event to ms */ #define LIMIT_FW_FATAL_EVENT_MS 10000 /* Qtimer Frequency */ #define QTIMER_FREQ 19200000 static DEFINE_RATELIMIT_STATE(errCnt, \ NL_BDCAST_RATELIMIT_INTERVAL, \ NL_BDCAST_RATELIMIT_BURST); struct log_msg { struct list_head node; unsigned int radio; unsigned int index; /* indicates the current filled log length in logbuf */ unsigned int filled_length; /* * Buf to hold the log msg * tAniHdr + log */ char logbuf[MAX_LOGMSG_LENGTH]; }; struct logger_log_complete { uint32_t is_fatal; uint32_t indicator; uint32_t reason_code; bool is_report_in_progress; bool is_flush_complete; uint32_t last_fw_bug_reason; unsigned long last_fw_bug_timestamp; }; struct fw_mem_dump_logging{ //It will hold the starting point of mem dump buffer uint8 *fw_dump_start_loc; //It will hold the current loc to tell how much data filled uint8 *fw_dump_current_loc; uint32 fw_dump_max_size; vos_pkt_t *fw_mem_dump_queue; /* Holds number of pkts in fw log vos pkt queue */ unsigned int fw_mem_dump_pkt_qcnt; /* Number of dropped pkts for fw dump */ unsigned int fw_mem_dump_pkt_drop_cnt; /* Lock to synchronize of queue/dequeue of pkts in fw log pkt queue */ spinlock_t fw_mem_dump_lock; /* Fw memory dump status */ enum FW_MEM_DUMP_STATE fw_mem_dump_status; /* storage for HDD callback which completes fw mem dump request */ void * svc_fw_mem_dump_req_cb; /* storage for HDD callback which completes fw mem dump request arg */ void * svc_fw_mem_dump_req_cb_arg; }; struct pkt_stats_msg { struct list_head node; /* indicates the current filled log length in pktlogbuf */ struct sk_buff *skb; }; struct perPktStatsInfo{ v_U32_t lastTxRate; // 802.11 data rate at which the last data frame is transmitted. v_U32_t txAvgRetry; // Average number of retries per 10 packets. v_S7_t avgRssi; // Average of the Beacon RSSI. }; struct wlan_logging { /* Log Fatal and ERROR to console */ bool log_fe_to_console; /* Number of buffers to be used for logging */ int num_buf; /* Lock to synchronize access to shared logging resource */ spinlock_t spin_lock; /* Holds the free node which can be used for filling logs */ struct list_head free_list; /* Holds the filled nodes which needs to be indicated to APP */ struct list_head filled_list; /* Points to head of logger pkt queue */ vos_pkt_t *data_mgmt_pkt_queue; /* Holds number of pkts in vos pkt queue */ unsigned int data_mgmt_pkt_qcnt; /* Lock to synchronize of queue/dequeue of pkts in logger pkt queue */ spinlock_t data_mgmt_pkt_lock; /* Points to head of logger fw log pkt queue */ vos_pkt_t *fw_log_pkt_queue; /* Holds number of pkts in fw log vos pkt queue */ unsigned int fw_log_pkt_qcnt; /* Lock to synchronize of queue/dequeue of pkts in fw log pkt queue */ spinlock_t fw_log_pkt_lock; /* Wait queue for Logger thread */ wait_queue_head_t wait_queue; /* Logger thread */ struct task_struct *thread; /* Logging thread sets this variable on exit */ struct completion shutdown_comp; /* Indicates to logger thread to exit */ bool exit; /* Holds number of dropped logs*/ unsigned int drop_count; /* Holds number of dropped vos pkts*/ unsigned int pkt_drop_cnt; /* Holds number of dropped fw log vos pkts*/ unsigned int fw_log_pkt_drop_cnt; /* current logbuf to which the log will be filled to */ struct log_msg *pcur_node; /* Event flag used for wakeup and post indication*/ unsigned long event_flag; /* Indicates logger thread is activated */ bool is_active; /* data structure for log complete event*/ struct logger_log_complete log_complete; spinlock_t bug_report_lock; struct fw_mem_dump_logging fw_mem_dump_ctx; int pkt_stat_num_buf; unsigned int pkt_stat_drop_cnt; unsigned int malloc_fail_count; struct list_head pkt_stat_free_list; struct list_head pkt_stat_filled_list; struct pkt_stats_msg *pkt_stats_pcur_node; /* Index of the messages sent to userspace */ unsigned int pkt_stats_msg_idx; bool pkt_stats_enabled; spinlock_t pkt_stats_lock; struct perPktStatsInfo txPktStatsInfo; }; static struct wlan_logging gwlan_logging; static struct log_msg *gplog_msg; static struct pkt_stats_msg *pkt_stats_buffers; /* PID of the APP to log the message */ static int gapp_pid = INVALID_PID; static char wlan_logging_ready[] = "WLAN LOGGING READY"; /* * Broadcast Logging service ready indication to any Logging application * Each netlink message will have a message of type tAniMsgHdr inside. */ void wlan_logging_srv_nl_ready_indication(void) { struct sk_buff *skb = NULL; struct nlmsghdr *nlh; tAniNlHdr *wnl = NULL; int payload_len; int err; static int rate_limit; payload_len = sizeof(tAniHdr) + sizeof(wlan_logging_ready) + sizeof(wnl->radio); skb = dev_alloc_skb(NLMSG_SPACE(payload_len)); if (NULL == skb) { if (!rate_limit) { LOGGING_TRACE(VOS_TRACE_LEVEL_ERROR, "NLINK: skb alloc fail %s", __func__); } rate_limit = 1; return; } rate_limit = 0; nlh = nlmsg_put(skb, 0, 0, ANI_NL_MSG_LOG, payload_len, NLM_F_REQUEST); if (NULL == nlh) { LOGGING_TRACE(VOS_TRACE_LEVEL_ERROR, "%s: nlmsg_put() failed for msg size[%d]", __func__, payload_len); kfree_skb(skb); return; } wnl = (tAniNlHdr *) nlh; wnl->radio = 0; wnl->wmsg.type = ANI_NL_MSG_READY_IND_TYPE; wnl->wmsg.length = sizeof(wlan_logging_ready); memcpy((char*)&wnl->wmsg + sizeof(tAniHdr), wlan_logging_ready, sizeof(wlan_logging_ready)); /* sender is in group 1<<0 */ NETLINK_CB(skb).dst_group = WLAN_NLINK_MCAST_GRP_ID; /*multicast the message to all listening processes*/ err = nl_srv_bcast(skb); if (err) { LOGGING_TRACE(VOS_TRACE_LEVEL_INFO_LOW, "NLINK: Ready Indication Send Fail %s, err %d", __func__, err); } return; } /* Utility function to send a netlink message to an application * in user space */ static int wlan_send_sock_msg_to_app(tAniHdr *wmsg, int radio, int src_mod, int pid) { int err = -1; int payload_len; int tot_msg_len; tAniNlHdr *wnl = NULL; struct sk_buff *skb; struct nlmsghdr *nlh; int wmsg_length = ntohs(wmsg->length); static int nlmsg_seq; if (radio < 0 || radio > ANI_MAX_RADIOS) { pr_err("%s: invalid radio id [%d]", __func__, radio); return -EINVAL; } payload_len = wmsg_length + sizeof(wnl->radio) + sizeof(tAniHdr); tot_msg_len = NLMSG_SPACE(payload_len); skb = dev_alloc_skb(tot_msg_len); if (skb == NULL) { pr_err("%s: dev_alloc_skb() failed for msg size[%d]", __func__, tot_msg_len); return -ENOMEM; } nlh = nlmsg_put(skb, pid, nlmsg_seq++, src_mod, payload_len, NLM_F_REQUEST); if (NULL == nlh) { pr_err("%s: nlmsg_put() failed for msg size[%d]", __func__, tot_msg_len); kfree_skb(skb); return -ENOMEM; } wnl = (tAniNlHdr *) nlh; wnl->radio = radio; vos_mem_copy(&wnl->wmsg, wmsg, wmsg_length); err = nl_srv_ucast(skb, pid, MSG_DONTWAIT); return err; } static void set_default_logtoapp_log_level(void) { vos_trace_setValue(VOS_MODULE_ID_WDI, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_PE, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_WDA, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_HDD_SOFTAP, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_SAP, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_PMC, VOS_TRACE_LEVEL_ALL, VOS_TRUE); vos_trace_setValue(VOS_MODULE_ID_SVC, VOS_TRACE_LEVEL_ALL, VOS_TRUE); } static void clear_default_logtoapp_log_level(void) { int module; for (module = 0; module < VOS_MODULE_ID_MAX; module++) { vos_trace_setValue(module, VOS_TRACE_LEVEL_NONE, VOS_FALSE); vos_trace_setValue(module, VOS_TRACE_LEVEL_FATAL, VOS_TRUE); vos_trace_setValue(module, VOS_TRACE_LEVEL_ERROR, VOS_TRUE); } vos_trace_setValue(VOS_MODULE_ID_RSV4, VOS_TRACE_LEVEL_NONE, VOS_FALSE); } /* Need to call this with spin_lock acquired */ static int wlan_queue_logmsg_for_app(void) { char *ptr; int ret = 0; ptr = &gwlan_logging.pcur_node->logbuf[sizeof(tAniHdr)]; ptr[gwlan_logging.pcur_node->filled_length] = '\0'; *(unsigned short *)(gwlan_logging.pcur_node->logbuf) = ANI_NL_MSG_LOG_TYPE; *(unsigned short *)(gwlan_logging.pcur_node->logbuf + 2) = gwlan_logging.pcur_node->filled_length; list_add_tail(&gwlan_logging.pcur_node->node, &gwlan_logging.filled_list); if (!list_empty(&gwlan_logging.free_list)) { /* Get buffer from free list */ gwlan_logging.pcur_node = (struct log_msg *)(gwlan_logging.free_list.next); list_del_init(gwlan_logging.free_list.next); } else if (!list_empty(&gwlan_logging.filled_list)) { /* Get buffer from filled list */ /* This condition will drop the packet from being * indicated to app */ gwlan_logging.pcur_node = (struct log_msg *)(gwlan_logging.filled_list.next); ++gwlan_logging.drop_count; /* print every 64th drop count */ if (vos_is_multicast_logging() && (!(gwlan_logging.drop_count % 0x40))) { pr_err("%s: drop_count = %u index = %d filled_length = %d\n", __func__, gwlan_logging.drop_count, gwlan_logging.pcur_node->index, gwlan_logging.pcur_node->filled_length); } list_del_init(gwlan_logging.filled_list.next); ret = 1; } /* Reset the current node values */ gwlan_logging.pcur_node->filled_length = 0; return ret; } void wlan_fillTxStruct(void *pktStat) { vos_mem_copy(&gwlan_logging.txPktStatsInfo, (struct perPktStatsInfo *)pktStat, sizeof(struct perPktStatsInfo)); } bool wlan_isPktStatsEnabled(void) { return gwlan_logging.pkt_stats_enabled; } /* Need to call this with spin_lock acquired */ static int wlan_queue_pkt_stats_for_app(struct sk_buff *skb_to_free) { int ret = 0; struct sk_buff *skb_new = NULL; struct pkt_stats_msg *tmp_node = NULL; if (!list_empty(&gwlan_logging.pkt_stat_free_list)) { /* Add current node to end of filled list */ list_add_tail(&gwlan_logging.pkt_stats_pcur_node->node, &gwlan_logging.pkt_stat_filled_list); /* Get buffer from free list */ gwlan_logging.pkt_stats_pcur_node = (struct pkt_stats_msg *)(gwlan_logging. pkt_stat_free_list.next); list_del_init(gwlan_logging.pkt_stat_free_list.next); } else if (!list_empty(&gwlan_logging.pkt_stat_filled_list)) { /* * Get buffer from filled list, free the skb and allocate a * new skb so that the current node has a clean skb */ tmp_node = (struct pkt_stats_msg *)(gwlan_logging. pkt_stat_filled_list.next); skb_new = dev_alloc_skb(MAX_PKTSTATS_LOG_LENGTH); if (skb_new == NULL) { /* Print error for every 512 malloc fails */ gwlan_logging.malloc_fail_count++; return -ENOMEM; } skb_to_free = tmp_node->skb; tmp_node->skb = skb_new; /* * This condition will drop the packet from being * indicated to app */ ++gwlan_logging.pkt_stat_drop_cnt; /* Add current node to end of filled list */ list_add_tail(&gwlan_logging.pkt_stats_pcur_node->node, &gwlan_logging.pkt_stat_filled_list); gwlan_logging.pkt_stats_pcur_node = tmp_node; list_del_init((struct list_head *) tmp_node); ret = 1; } /* Reset the current node values */ gwlan_logging.pkt_stats_pcur_node-> skb->len = 0; return ret; } int wlan_pkt_stats_to_user(void *perPktStat) { bool wake_up_thread = false; tPerPacketStats *pktstats = perPktStat; unsigned long flags; tx_rx_pkt_stats rx_tx_stats; int total_log_len = 0; int ret = 0; struct sk_buff *ptr; struct sk_buff *skb_to_free = NULL; tpSirMacMgmtHdr hdr; uint32 rateIdx; if (!vos_is_multicast_logging()) { return -EIO; } if (vos_is_multicast_logging()) { vos_mem_zero(&rx_tx_stats, sizeof(tx_rx_pkt_stats)); if (pktstats->is_rx){ rx_tx_stats.ps_hdr.flags = (1 << PKTLOG_FLG_FRM_TYPE_REMOTE_S); }else{ rx_tx_stats.ps_hdr.flags = (1 << PKTLOG_FLG_FRM_TYPE_LOCAL_S); } /*Send log type as PKTLOG_TYPE_PKT_STAT (9)*/ rx_tx_stats.ps_hdr.log_type = PKTLOG_TYPE_PKT_STAT; rx_tx_stats.ps_hdr.timestamp = vos_timer_get_system_ticks(); rx_tx_stats.ps_hdr.missed_cnt = 0; rx_tx_stats.ps_hdr.size = sizeof(tx_rx_pkt_stats) - sizeof(pkt_stats_hdr) + pktstats->data_len- MAX_PKT_STAT_DATA_LEN; rx_tx_stats.stats.flags |= PER_PACKET_ENTRY_FLAGS_TX_SUCCESS; rx_tx_stats.stats.flags |= PER_PACKET_ENTRY_FLAGS_80211_HEADER; if (pktstats->is_rx) rx_tx_stats.stats.flags |= PER_PACKET_ENTRY_FLAGS_DIRECTION_TX; hdr = (tpSirMacMgmtHdr)pktstats->data; if (hdr->fc.wep) { rx_tx_stats.stats.flags |= PER_PACKET_ENTRY_FLAGS_PROTECTED; /* Reset wep bit to parse frame properly */ hdr->fc.wep = 0; } rx_tx_stats.stats.tid = pktstats->tid; rx_tx_stats.stats.dxe_timestamp = pktstats->dxe_timestamp; if (!pktstats->is_rx) { rx_tx_stats.stats.rssi = gwlan_logging.txPktStatsInfo.avgRssi; rx_tx_stats.stats.num_retries = gwlan_logging.txPktStatsInfo.txAvgRetry; rateIdx = gwlan_logging.txPktStatsInfo.lastTxRate; } else { rx_tx_stats.stats.rssi = pktstats->rssi; rx_tx_stats.stats.num_retries = pktstats->num_retries; rateIdx = pktstats->rate_idx; } rx_tx_stats.stats.link_layer_transmit_sequence = pktstats->seq_num; /* Calculate rate and MCS from rate index */ if( rateIdx >= 210 && rateIdx <= 217) rateIdx-=202; if( rateIdx >= 218 && rateIdx <= 225 ) rateIdx-=210; get_rate_and_MCS(&rx_tx_stats.stats, rateIdx); vos_mem_copy(rx_tx_stats.stats.data,pktstats->data, pktstats->data_len); /* 1+1 indicate '\n'+'\0' */ total_log_len = sizeof(tx_rx_pkt_stats) + pktstats->data_len - MAX_PKT_STAT_DATA_LEN; spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, flags); // wlan logging svc resources are not yet initialized if (!gwlan_logging.pkt_stats_pcur_node) { pr_err("%s, logging svc not initialized", __func__); spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags); return -EIO; } /* Check if we can accomodate more log into current node/buffer */ if (total_log_len + sizeof(vos_log_pktlog_info) + sizeof(tAniNlHdr) >= skb_tailroom(gwlan_logging.pkt_stats_pcur_node->skb)) { ret = wlan_queue_pkt_stats_for_app(skb_to_free); if (ret == -ENOMEM) { spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags); /* Print every 64 malloc fails */ if (!(gwlan_logging.malloc_fail_count % 64)) pr_err("%s: dev_alloc_skb() failed for msg size[%d]", __func__, MAX_PKTSTATS_LOG_LENGTH); return ret; } wake_up_thread = true; } ptr = gwlan_logging.pkt_stats_pcur_node->skb; vos_mem_copy(skb_put(ptr, total_log_len), &rx_tx_stats, total_log_len); spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags); /* * If ret is non-zero and not ENOMEM, we have re-allocated from * filled list, free the older skb and print every 64th drop count */ if (ret) { if (skb_to_free) dev_kfree_skb(skb_to_free); /* print every 64th drop count */ if (vos_is_multicast_logging() && (!(gwlan_logging.pkt_stat_drop_cnt % 0x40))) { pr_err("%s: drop_count = %u\n", __func__, gwlan_logging.pkt_stat_drop_cnt); } } /* Wakeup logger thread */ if ((true == wake_up_thread)) { /* If there is logger app registered wakeup the logging * thread */ set_bit(HOST_PKT_STATS_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } } return 0; } void wlan_disable_and_flush_pkt_stats() { unsigned long flags; int ret = 0; struct sk_buff *skb_to_free = NULL; spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, flags); if(gwlan_logging.pkt_stats_pcur_node->skb->len){ ret = wlan_queue_pkt_stats_for_app(skb_to_free); } spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags); /* * If ret is non-zero and not ENOMEM, we have re-allocated from * filled list, free the older skb and print every 64th drop count */ if (ret == -ENOMEM) { /* Print every 64 malloc fails */ if (!(gwlan_logging.malloc_fail_count % 64)) pr_err("%s: dev_alloc_skb() failed for msg size[%d]", __func__, MAX_PKTSTATS_LOG_LENGTH); } else if (ret) { if (skb_to_free) dev_kfree_skb(skb_to_free); /* print every 64th drop count */ if (vos_is_multicast_logging() && (!(gwlan_logging.pkt_stat_drop_cnt % 0x40))) { pr_err("%s: drop_count = %u\n", __func__, gwlan_logging.pkt_stat_drop_cnt); } } set_bit(HOST_PKT_STATS_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } int wlan_log_to_user(VOS_TRACE_LEVEL log_level, char *to_be_sent, int length) { /* Add the current time stamp */ char *ptr; char tbuf[100]; int tlen; int total_log_len; unsigned int *pfilled_length; bool wake_up_thread = false; unsigned long flags; struct timeval tv; struct rtc_time tm; unsigned long local_time; u64 qtimer_ticks; if (!vos_is_multicast_logging()) { /* * This is to make sure that we print the logs to kmsg console * when no logger app is running. This is also needed to * log the initial messages during loading of driver where even * if app is running it will not be able to * register with driver immediately and start logging all the * messages. */ pr_err("%s\n", to_be_sent); } else { /* Format the Log time [hr:min:sec.microsec] */ do_gettimeofday(&tv); /* Convert rtc to local time */ local_time = (u32)(tv.tv_sec - (sys_tz.tz_minuteswest * 60)); rtc_time_to_tm(local_time, &tm); /* Firmware Time Stamp */ qtimer_ticks = __vos_get_log_timestamp(); tlen = snprintf(tbuf, sizeof(tbuf), "[%02d:%02d:%02d.%06lu] [%016llX]" " [%.5s] ", tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec, qtimer_ticks, current->comm); /* 1+1 indicate '\n'+'\0' */ total_log_len = length + tlen + 1 + 1; spin_lock_irqsave(&gwlan_logging.spin_lock, flags); // wlan logging svc resources are not yet initialized if (!gwlan_logging.pcur_node) { spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); return -EIO; } pfilled_length = &gwlan_logging.pcur_node->filled_length; /* Check if we can accomodate more log into current node/buffer */ if (MAX_LOGMSG_LENGTH < (*pfilled_length + sizeof(tAniNlHdr) + total_log_len)) { wake_up_thread = true; wlan_queue_logmsg_for_app(); pfilled_length = &gwlan_logging.pcur_node->filled_length; } ptr = &gwlan_logging.pcur_node->logbuf[sizeof(tAniHdr)]; /* Assumption here is that we receive logs which is always less than * MAX_LOGMSG_LENGTH, where we can accomodate the * tAniNlHdr + [context][timestamp] + log * VOS_ASSERT if we cannot accomodate the the complete log into * the available buffer. * * Continue and copy logs to the available length and discard the rest. */ if (MAX_LOGMSG_LENGTH < (sizeof(tAniNlHdr) + total_log_len)) { VOS_ASSERT(0); total_log_len = MAX_LOGMSG_LENGTH - sizeof(tAniNlHdr) - 2; } vos_mem_copy(&ptr[*pfilled_length], tbuf, tlen); vos_mem_copy(&ptr[*pfilled_length + tlen], to_be_sent, min(length, (total_log_len - tlen))); *pfilled_length += tlen + min(length, total_log_len - tlen); ptr[*pfilled_length] = '\n'; *pfilled_length += 1; spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); /* Wakeup logger thread */ if ((true == wake_up_thread)) { /* If there is logger app registered wakeup the logging * thread */ set_bit(HOST_LOG_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } if (gwlan_logging.log_fe_to_console && ((VOS_TRACE_LEVEL_FATAL == log_level) || (VOS_TRACE_LEVEL_ERROR == log_level))) { pr_err("%s %s\n",tbuf, to_be_sent); } } return 0; } static int send_fw_log_pkt_to_user(void) { int ret = -1; int extra_header_len, nl_payload_len; struct sk_buff *skb = NULL; static int nlmsg_seq; vos_pkt_t *current_pkt; vos_pkt_t *next_pkt; VOS_STATUS status = VOS_STATUS_E_FAILURE; unsigned long flags; tAniNlHdr msg_header; do { spin_lock_irqsave(&gwlan_logging.fw_log_pkt_lock, flags); if (!gwlan_logging.fw_log_pkt_queue) { spin_unlock_irqrestore( &gwlan_logging.fw_log_pkt_lock, flags); return -EIO; } /* pick first pkt from queued chain */ current_pkt = gwlan_logging.fw_log_pkt_queue; /* get the pointer to the next packet in the chain */ status = vos_pkt_walk_packet_chain(current_pkt, &next_pkt, TRUE); /* both "success" and "empty" are acceptable results */ if (!((status == VOS_STATUS_SUCCESS) || (status == VOS_STATUS_E_EMPTY))) { ++gwlan_logging.fw_log_pkt_drop_cnt; spin_unlock_irqrestore( &gwlan_logging.fw_log_pkt_lock, flags); pr_err("%s: Failure walking packet chain", __func__); return -EIO; } /* update queue head with next pkt ptr which could be NULL */ gwlan_logging.fw_log_pkt_queue = next_pkt; --gwlan_logging.fw_log_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.fw_log_pkt_lock, flags); status = vos_pkt_get_os_packet(current_pkt, (v_VOID_t **)&skb, TRUE); if (!VOS_IS_STATUS_SUCCESS(status)) { ++gwlan_logging.fw_log_pkt_drop_cnt; pr_err("%s: Failure extracting skb from vos pkt", __func__); return -EIO; } /*return vos pkt since skb is already detached */ vos_pkt_return_packet(current_pkt); extra_header_len = sizeof(msg_header.radio) + sizeof(tAniHdr); nl_payload_len = extra_header_len + skb->len; msg_header.nlh.nlmsg_type = ANI_NL_MSG_LOG; msg_header.nlh.nlmsg_len = nlmsg_msg_size(nl_payload_len); msg_header.nlh.nlmsg_flags = NLM_F_REQUEST; msg_header.nlh.nlmsg_pid = gapp_pid; msg_header.nlh.nlmsg_seq = nlmsg_seq++; msg_header.radio = 0; msg_header.wmsg.type = ANI_NL_MSG_FW_LOG_PKT_TYPE; msg_header.wmsg.length = skb->len; if (unlikely(skb_headroom(skb) < sizeof(msg_header))) { pr_err("VPKT [%d]: Insufficient headroom, head[%pK]," " data[%pK], req[%zu]", __LINE__, skb->head, skb->data, sizeof(msg_header)); return -EIO; } vos_mem_copy(skb_push(skb, sizeof(msg_header)), &msg_header, sizeof(msg_header)); ret = nl_srv_bcast(skb); if ((ret < 0) && (ret != -ESRCH)) { pr_info("%s: Send Failed %d drop_count = %u\n", __func__, ret, ++gwlan_logging.fw_log_pkt_drop_cnt); } else { ret = 0; } } while (next_pkt); return ret; } static int send_data_mgmt_log_pkt_to_user(void) { int ret = -1; int extra_header_len, nl_payload_len; struct sk_buff *skb = NULL; static int nlmsg_seq; vos_pkt_t *current_pkt; vos_pkt_t *next_pkt; VOS_STATUS status = VOS_STATUS_E_FAILURE; unsigned long flags; tAniNlLogHdr msg_header; do { spin_lock_irqsave(&gwlan_logging.data_mgmt_pkt_lock, flags); if (!gwlan_logging.data_mgmt_pkt_queue) { spin_unlock_irqrestore( &gwlan_logging.data_mgmt_pkt_lock, flags); return -EIO; } /* pick first pkt from queued chain */ current_pkt = gwlan_logging.data_mgmt_pkt_queue; /* get the pointer to the next packet in the chain */ status = vos_pkt_walk_packet_chain(current_pkt, &next_pkt, TRUE); /* both "success" and "empty" are acceptable results */ if (!((status == VOS_STATUS_SUCCESS) || (status == VOS_STATUS_E_EMPTY))) { ++gwlan_logging.pkt_drop_cnt; spin_unlock_irqrestore( &gwlan_logging.data_mgmt_pkt_lock, flags); pr_err("%s: Failure walking packet chain", __func__); return -EIO; } /* update queue head with next pkt ptr which could be NULL */ gwlan_logging.data_mgmt_pkt_queue = next_pkt; --gwlan_logging.data_mgmt_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.data_mgmt_pkt_lock, flags); status = vos_pkt_get_os_packet(current_pkt, (v_VOID_t **)&skb, TRUE); if (!VOS_IS_STATUS_SUCCESS(status)) { ++gwlan_logging.pkt_drop_cnt; pr_err("%s: Failure extracting skb from vos pkt", __func__); return -EIO; } /*return vos pkt since skb is already detached */ vos_pkt_return_packet(current_pkt); extra_header_len = sizeof(msg_header.radio) + sizeof(tAniHdr) + sizeof(msg_header.frameSize); nl_payload_len = extra_header_len + skb->len; msg_header.nlh.nlmsg_type = ANI_NL_MSG_LOG; msg_header.nlh.nlmsg_len = nlmsg_msg_size(nl_payload_len); msg_header.nlh.nlmsg_flags = NLM_F_REQUEST; msg_header.nlh.nlmsg_pid = 0; msg_header.nlh.nlmsg_seq = nlmsg_seq++; msg_header.radio = 0; msg_header.wmsg.type = ANI_NL_MSG_LOG_PKT_TYPE; msg_header.wmsg.length = skb->len + sizeof(uint32); msg_header.frameSize = WLAN_MGMT_LOGGING_FRAMESIZE_128BYTES; if (unlikely(skb_headroom(skb) < sizeof(msg_header))) { pr_err("VPKT [%d]: Insufficient headroom, head[%pK]," " data[%pK], req[%zu]", __LINE__, skb->head, skb->data, sizeof(msg_header)); return -EIO; } vos_mem_copy(skb_push(skb, sizeof(msg_header)), &msg_header, sizeof(msg_header)); ret = nl_srv_bcast(skb); if (ret < 0) { pr_info("%s: Send Failed %d drop_count = %u\n", __func__, ret, ++gwlan_logging.pkt_drop_cnt); } else { ret = 0; } } while (next_pkt); return ret; } static int fill_fw_mem_dump_buffer(void) { struct sk_buff *skb = NULL; vos_pkt_t *current_pkt; vos_pkt_t *next_pkt; VOS_STATUS status = VOS_STATUS_E_FAILURE; unsigned long flags; int byte_left = 0; do { spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); if (!gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue) { spin_unlock_irqrestore( &gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); return -EIO; } /* pick first pkt from queued chain */ current_pkt = gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue; /* get the pointer to the next packet in the chain */ status = vos_pkt_walk_packet_chain(current_pkt, &next_pkt, TRUE); /* both "success" and "empty" are acceptable results */ if (!((status == VOS_STATUS_SUCCESS) || (status == VOS_STATUS_E_EMPTY))) { spin_unlock_irqrestore( &gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); pr_err("%s: Failure walking packet chain", __func__); return -EIO; } /* update queue head with next pkt ptr which could be NULL */ gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue = next_pkt; --gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); status = vos_pkt_get_os_packet(current_pkt, (v_VOID_t **)&skb, VOS_FALSE); if (!VOS_IS_STATUS_SUCCESS(status)) { pr_err("%s: Failure extracting skb from vos pkt", __func__); return -EIO; } //Copy data from SKB to mem dump buffer spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); if((skb) && (skb->len != 0)) { // Prevent buffer overflow byte_left = ((int)gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size - (int)(gwlan_logging.fw_mem_dump_ctx.fw_dump_current_loc - gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc)); if(skb->len > byte_left) { vos_mem_copy(gwlan_logging.fw_mem_dump_ctx.fw_dump_current_loc, skb->data, byte_left); //Update the current location ptr gwlan_logging.fw_mem_dump_ctx.fw_dump_current_loc += byte_left; } else { vos_mem_copy(gwlan_logging.fw_mem_dump_ctx.fw_dump_current_loc, skb->data, skb->len); //Update the current location ptr gwlan_logging.fw_mem_dump_ctx.fw_dump_current_loc += skb->len; } } spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); /*return vos pkt since skb is already detached */ vos_pkt_return_packet(current_pkt); } while (next_pkt); return 0; } static int send_filled_buffers_to_user(void) { int ret = -1; struct log_msg *plog_msg; int payload_len; int tot_msg_len; tAniNlHdr *wnl; struct sk_buff *skb = NULL; struct nlmsghdr *nlh; static int nlmsg_seq; unsigned long flags; static int rate_limit; while (!list_empty(&gwlan_logging.filled_list) && !gwlan_logging.exit) { skb = dev_alloc_skb(MAX_LOGMSG_LENGTH); if (skb == NULL) { if (!rate_limit) { pr_err("%s: dev_alloc_skb() failed for msg size[%d] drop count = %u\n", __func__, MAX_LOGMSG_LENGTH, gwlan_logging.drop_count); } rate_limit = 1; ret = -ENOMEM; break; } rate_limit = 0; spin_lock_irqsave(&gwlan_logging.spin_lock, flags); plog_msg = (struct log_msg *) (gwlan_logging.filled_list.next); list_del_init(gwlan_logging.filled_list.next); spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); /* 4 extra bytes for the radio idx */ payload_len = plog_msg->filled_length + sizeof(wnl->radio) + sizeof(tAniHdr); tot_msg_len = NLMSG_SPACE(payload_len); nlh = nlmsg_put(skb, 0, nlmsg_seq++, ANI_NL_MSG_LOG, payload_len, NLM_F_REQUEST); if (NULL == nlh) { spin_lock_irqsave(&gwlan_logging.spin_lock, flags); list_add_tail(&plog_msg->node, &gwlan_logging.free_list); spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); pr_err("%s: drop_count = %u\n", __func__, ++gwlan_logging.drop_count); pr_err("%s: nlmsg_put() failed for msg size[%d]\n", __func__, tot_msg_len); dev_kfree_skb(skb); skb = NULL; ret = -EINVAL; continue; } wnl = (tAniNlHdr *) nlh; wnl->radio = plog_msg->radio; vos_mem_copy(&wnl->wmsg, plog_msg->logbuf, plog_msg->filled_length + sizeof(tAniHdr)); spin_lock_irqsave(&gwlan_logging.spin_lock, flags); list_add_tail(&plog_msg->node, &gwlan_logging.free_list); spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); ret = nl_srv_bcast(skb); if (ret < 0) { if (__ratelimit(&errCnt)) { pr_info("%s: Send Failed %d drop_count = %u\n", __func__, ret, gwlan_logging.drop_count); } gwlan_logging.drop_count++; skb = NULL; break; } else { skb = NULL; ret = 0; } } return ret; } static int send_per_pkt_stats_to_user(void) { int ret = -1; struct pkt_stats_msg *plog_msg; unsigned long flags; struct sk_buff *skb_new = NULL; vos_log_pktlog_info pktlog; tAniNlHdr msg_header; int extra_header_len, nl_payload_len; static int nlmsg_seq; static int rate_limit; int diag_type; bool free_old_skb = false; while (!list_empty(&gwlan_logging.pkt_stat_filled_list) && !gwlan_logging.exit) { skb_new= dev_alloc_skb(MAX_PKTSTATS_LOG_LENGTH); if (skb_new == NULL) { if (!rate_limit) { pr_err("%s: dev_alloc_skb() failed for msg size[%d] drop count = %u\n", __func__, MAX_LOGMSG_LENGTH, gwlan_logging.drop_count); } rate_limit = 1; ret = -ENOMEM; break; } spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, flags); plog_msg = (struct pkt_stats_msg *) (gwlan_logging.pkt_stat_filled_list.next); list_del_init(gwlan_logging.pkt_stat_filled_list.next); spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags); vos_mem_zero(&pktlog, sizeof(vos_log_pktlog_info)); vos_log_set_code(&pktlog, LOG_WLAN_PKT_LOG_INFO_C); pktlog.version = VERSION_LOG_WLAN_PKT_LOG_INFO_C; pktlog.buf_len = plog_msg->skb->len; vos_log_set_length(&pktlog.log_hdr, plog_msg->skb->len + sizeof(vos_log_pktlog_info)); pktlog.seq_no = gwlan_logging.pkt_stats_msg_idx++; if (unlikely(skb_headroom(plog_msg->skb) < sizeof(vos_log_pktlog_info))) { pr_err("VPKT [%d]: Insufficient headroom, head[%pK]," " data[%pK], req[%zu]", __LINE__, plog_msg->skb->head, plog_msg->skb->data, sizeof(msg_header)); ret = -EIO; free_old_skb = true; goto err; } vos_mem_copy(skb_push(plog_msg->skb, sizeof(vos_log_pktlog_info)), &pktlog, sizeof(vos_log_pktlog_info)); if (unlikely(skb_headroom(plog_msg->skb) < sizeof(int))) { pr_err("VPKT [%d]: Insufficient headroom, head[%pK]," " data[%pK], req[%zu]", __LINE__, plog_msg->skb->head, plog_msg->skb->data, sizeof(int)); ret = -EIO; free_old_skb = true; goto err; } diag_type = DIAG_TYPE_LOGS; vos_mem_copy(skb_push(plog_msg->skb, sizeof(int)), &diag_type, sizeof(int)); extra_header_len = sizeof(msg_header.radio) + sizeof(tAniHdr); nl_payload_len = extra_header_len + plog_msg->skb->len; msg_header.nlh.nlmsg_type = ANI_NL_MSG_PUMAC; msg_header.nlh.nlmsg_len = nlmsg_msg_size(nl_payload_len); msg_header.nlh.nlmsg_flags = NLM_F_REQUEST; msg_header.nlh.nlmsg_pid = 0; msg_header.nlh.nlmsg_seq = nlmsg_seq++; msg_header.radio = 0; msg_header.wmsg.type = PTT_MSG_DIAG_CMDS_TYPE; msg_header.wmsg.length = cpu_to_be16(plog_msg->skb->len); if (unlikely(skb_headroom(plog_msg->skb) < sizeof(msg_header))) { pr_err("VPKT [%d]: Insufficient headroom, head[%pK]," " data[%pK], req[%zu]", __LINE__, plog_msg->skb->head, plog_msg->skb->data, sizeof(msg_header)); ret = -EIO; free_old_skb = true; goto err; } vos_mem_copy(skb_push(plog_msg->skb, sizeof(msg_header)), &msg_header, sizeof(msg_header)); ret = nl_srv_bcast(plog_msg->skb); if (ret < 0) { pr_info("%s: Send Failed %d drop_count = %u\n", __func__, ret, ++gwlan_logging.fw_log_pkt_drop_cnt); } else { ret = 0; } err: /* * Free old skb in case or error before assigning new skb * to the free list. */ if (free_old_skb) dev_kfree_skb(plog_msg->skb); spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, flags); plog_msg->skb = skb_new; list_add_tail(&plog_msg->node, &gwlan_logging.pkt_stat_free_list); spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, flags); ret = 0; } return ret; } /** * wlan_logging_thread() - The WLAN Logger thread * @Arg - pointer to the HDD context * * This thread logs log message to App registered for the logs. */ static int wlan_logging_thread(void *Arg) { int ret_wait_status = 0; int ret = 0; unsigned long flags; set_user_nice(current, -2); #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 8, 0)) daemonize("wlan_logging_thread"); #endif while (!gwlan_logging.exit) { ret_wait_status = wait_event_interruptible( gwlan_logging.wait_queue, (test_bit(HOST_LOG_POST, &gwlan_logging.event_flag) || gwlan_logging.exit || test_bit(LOGGER_MGMT_DATA_PKT_POST, &gwlan_logging.event_flag) || test_bit(LOGGER_FW_LOG_PKT_POST, &gwlan_logging.event_flag) || test_bit(LOGGER_FATAL_EVENT_POST, &gwlan_logging.event_flag) || test_bit(LOGGER_FW_MEM_DUMP_PKT_POST, &gwlan_logging.event_flag) || test_bit(LOGGER_FW_MEM_DUMP_PKT_POST_DONE, &gwlan_logging.event_flag)|| test_bit(HOST_PKT_STATS_POST, &gwlan_logging.event_flag))); if (ret_wait_status == -ERESTARTSYS) { pr_err("%s: wait_event return -ERESTARTSYS", __func__); break; } if (gwlan_logging.exit) { break; } if (test_and_clear_bit(HOST_LOG_POST, &gwlan_logging.event_flag)) { ret = send_filled_buffers_to_user(); if (-ENOMEM == ret) { msleep(200); } if (WLAN_LOG_INDICATOR_HOST_ONLY == gwlan_logging.log_complete.indicator) { vos_send_fatal_event_done(); } } if (test_and_clear_bit(LOGGER_FW_LOG_PKT_POST, &gwlan_logging.event_flag)) { send_fw_log_pkt_to_user(); } if (test_and_clear_bit(LOGGER_MGMT_DATA_PKT_POST, &gwlan_logging.event_flag)) { send_data_mgmt_log_pkt_to_user(); } if (test_and_clear_bit(LOGGER_FATAL_EVENT_POST, &gwlan_logging.event_flag)) { if (gwlan_logging.log_complete.is_flush_complete == true) { gwlan_logging.log_complete.is_flush_complete = false; vos_send_fatal_event_done(); } else { gwlan_logging.log_complete.is_flush_complete = true; spin_lock_irqsave(&gwlan_logging.spin_lock, flags); /* Flush all current host logs*/ wlan_queue_logmsg_for_app(); spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); set_bit(HOST_LOG_POST,&gwlan_logging.event_flag); set_bit(LOGGER_FW_LOG_PKT_POST, &gwlan_logging.event_flag); set_bit(LOGGER_FATAL_EVENT_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } } if (test_and_clear_bit(LOGGER_FW_MEM_DUMP_PKT_POST, &gwlan_logging.event_flag)) { fill_fw_mem_dump_buffer(); } if(test_and_clear_bit(LOGGER_FW_MEM_DUMP_PKT_POST_DONE, &gwlan_logging.event_flag)){ spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock,flags); /*Chnage fw memory dump to indicate write done*/ gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status = FW_MEM_DUMP_WRITE_DONE; /*reset dropped packet count upon completion of this request*/ gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_pkt_drop_cnt = 0; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock,flags); fill_fw_mem_dump_buffer(); /* * Call the registered HDD callback for indicating * memdump complete. If it's null,then something is * not right. */ if (gwlan_logging.fw_mem_dump_ctx.svc_fw_mem_dump_req_cb) { ((hdd_fw_mem_dump_req_cb) gwlan_logging.fw_mem_dump_ctx.svc_fw_mem_dump_req_cb)( gwlan_logging.fw_mem_dump_ctx.svc_fw_mem_dump_req_cb_arg); /*invalidate the callback pointers*/ spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock,flags); gwlan_logging.fw_mem_dump_ctx.svc_fw_mem_dump_req_cb = NULL; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock,flags); } } if (test_and_clear_bit(HOST_PKT_STATS_POST, &gwlan_logging.event_flag)) { send_per_pkt_stats_to_user(); } } complete(&gwlan_logging.shutdown_comp); do_exit(0); return 0; } /* * Process all the Netlink messages from Logger Socket app in user space */ static int wlan_logging_proc_sock_rx_msg(struct sk_buff *skb) { tAniNlHdr *wnl; int radio; int type; int ret, len; unsigned long flags; if (TRUE == vos_isUnloadInProgress()) { pr_info("%s: unload in progress\n",__func__); return -ENODEV; } wnl = (tAniNlHdr *) skb->data; radio = wnl->radio; type = wnl->nlh.nlmsg_type; if (radio < 0 || radio > ANI_MAX_RADIOS) { pr_err("%s: invalid radio id [%d]\n", __func__, radio); return -EINVAL; } len = ntohs(wnl->wmsg.length) + sizeof(tAniNlHdr); if (len > skb_headlen(skb)) { pr_err("%s: invalid length, msgLen:%x skb len:%x headLen: %d data_len: %d", __func__, len, skb->len, skb_headlen(skb), skb->data_len); return -EINVAL; } if (gapp_pid != INVALID_PID) { if (wnl->nlh.nlmsg_pid > gapp_pid) { gapp_pid = wnl->nlh.nlmsg_pid; } spin_lock_irqsave(&gwlan_logging.spin_lock, flags); if (gwlan_logging.pcur_node->filled_length) { wlan_queue_logmsg_for_app(); } spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); set_bit(HOST_LOG_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } else { /* This is to set the default levels (WLAN logging * default values not the VOS trace default) when * logger app is registered for the first time. */ gapp_pid = wnl->nlh.nlmsg_pid; } ret = wlan_send_sock_msg_to_app(&wnl->wmsg, 0, ANI_NL_MSG_LOG, wnl->nlh.nlmsg_pid); if (ret < 0) { pr_err("wlan_send_sock_msg_to_app: failed"); } return ret; } void wlan_init_log_completion(void) { gwlan_logging.log_complete.indicator = WLAN_LOG_INDICATOR_UNUSED; gwlan_logging.log_complete.is_fatal = WLAN_LOG_TYPE_NON_FATAL; gwlan_logging.log_complete.is_report_in_progress = false; gwlan_logging.log_complete.reason_code = WLAN_LOG_REASON_CODE_UNUSED; gwlan_logging.log_complete.last_fw_bug_reason = 0; gwlan_logging.log_complete.last_fw_bug_timestamp = 0; spin_lock_init(&gwlan_logging.bug_report_lock); } int wlan_set_log_completion(uint32 is_fatal, uint32 indicator, uint32 reason_code) { unsigned long flags; spin_lock_irqsave(&gwlan_logging.bug_report_lock, flags); gwlan_logging.log_complete.indicator = indicator; gwlan_logging.log_complete.is_fatal = is_fatal; gwlan_logging.log_complete.is_report_in_progress = true; gwlan_logging.log_complete.reason_code = reason_code; spin_unlock_irqrestore(&gwlan_logging.bug_report_lock, flags); return 0; } void wlan_get_log_and_reset_completion(uint32 *is_fatal, uint32 *indicator, uint32 *reason_code, bool reset) { unsigned long flags; spin_lock_irqsave(&gwlan_logging.bug_report_lock, flags); *indicator = gwlan_logging.log_complete.indicator; *is_fatal = gwlan_logging.log_complete.is_fatal; *reason_code = gwlan_logging.log_complete.reason_code; if (reset) { gwlan_logging.log_complete.indicator = WLAN_LOG_INDICATOR_UNUSED; gwlan_logging.log_complete.is_fatal = WLAN_LOG_TYPE_NON_FATAL; gwlan_logging.log_complete.is_report_in_progress = false; gwlan_logging.log_complete.reason_code = WLAN_LOG_REASON_CODE_UNUSED; } spin_unlock_irqrestore(&gwlan_logging.bug_report_lock, flags); } bool wlan_is_log_report_in_progress(void) { return gwlan_logging.log_complete.is_report_in_progress; } void wlan_reset_log_report_in_progress(void) { unsigned long flags; spin_lock_irqsave(&gwlan_logging.bug_report_lock, flags); gwlan_logging.log_complete.is_report_in_progress = false; spin_unlock_irqrestore(&gwlan_logging.bug_report_lock, flags); } void wlan_deinit_log_completion(void) { return; } int wlan_logging_sock_activate_svc(int log_fe_to_console, int num_buf, int pkt_stats_enabled, int pkt_stats_buff) { int i, j = 0; unsigned long irq_flag; bool failure = FALSE; struct log_msg *temp; pr_info("%s: Initalizing FEConsoleLog = %d NumBuff = %d\n", __func__, log_fe_to_console, num_buf); gapp_pid = INVALID_PID; gplog_msg = (struct log_msg *) vmalloc( num_buf * sizeof(struct log_msg)); if (!gplog_msg) { pr_err("%s: Could not allocate memory\n", __func__); return -ENOMEM; } vos_mem_zero(gplog_msg, (num_buf * sizeof(struct log_msg))); gwlan_logging.log_fe_to_console = !!log_fe_to_console; gwlan_logging.num_buf = num_buf; spin_lock_irqsave(&gwlan_logging.spin_lock, irq_flag); INIT_LIST_HEAD(&gwlan_logging.free_list); INIT_LIST_HEAD(&gwlan_logging.filled_list); for (i = 0; i < num_buf; i++) { list_add(&gplog_msg[i].node, &gwlan_logging.free_list); gplog_msg[i].index = i; } gwlan_logging.pcur_node = (struct log_msg *) (gwlan_logging.free_list.next); list_del_init(gwlan_logging.free_list.next); spin_unlock_irqrestore(&gwlan_logging.spin_lock, irq_flag); if(pkt_stats_enabled) { pr_info("%s: Initalizing Pkt stats pkt_stats_buff = %d\n", __func__, pkt_stats_buff); pkt_stats_buffers = (struct pkt_stats_msg *) vos_mem_malloc( pkt_stats_buff * sizeof(struct pkt_stats_msg)); if (!pkt_stats_buffers) { pr_err("%s: Could not allocate memory for Pkt stats\n", __func__); failure = TRUE; goto err; } gwlan_logging.pkt_stat_num_buf = pkt_stats_buff; gwlan_logging.pkt_stats_msg_idx = 0; INIT_LIST_HEAD(&gwlan_logging.pkt_stat_free_list); INIT_LIST_HEAD(&gwlan_logging.pkt_stat_filled_list); for (i = 0; i < pkt_stats_buff; i++) { pkt_stats_buffers[i].skb= dev_alloc_skb(MAX_PKTSTATS_LOG_LENGTH); if (pkt_stats_buffers[i].skb == NULL) { pr_err("%s: Memory alloc failed for skb",__func__); /* free previously allocated skb and return;*/ for (j = 0; j<i ; j++) { dev_kfree_skb(pkt_stats_buffers[j].skb); } spin_lock_irqsave(&gwlan_logging.spin_lock, irq_flag); gwlan_logging.pkt_stat_num_buf = 0; vos_mem_free(pkt_stats_buffers); pkt_stats_buffers = NULL; spin_unlock_irqrestore(&gwlan_logging.spin_lock, irq_flag); failure = TRUE; goto err; } list_add(&pkt_stats_buffers[i].node, &gwlan_logging.pkt_stat_free_list); } gwlan_logging.pkt_stats_pcur_node = (struct pkt_stats_msg *) (gwlan_logging.pkt_stat_free_list.next); list_del_init(gwlan_logging.pkt_stat_free_list.next); gwlan_logging.pkt_stats_enabled = TRUE; } err: if (failure) gwlan_logging.pkt_stats_enabled = false; init_waitqueue_head(&gwlan_logging.wait_queue); gwlan_logging.exit = false; clear_bit(HOST_LOG_POST, &gwlan_logging.event_flag); clear_bit(LOGGER_MGMT_DATA_PKT_POST, &gwlan_logging.event_flag); clear_bit(LOGGER_FW_LOG_PKT_POST, &gwlan_logging.event_flag); clear_bit(LOGGER_FATAL_EVENT_POST, &gwlan_logging.event_flag); clear_bit(HOST_PKT_STATS_POST, &gwlan_logging.event_flag); init_completion(&gwlan_logging.shutdown_comp); gwlan_logging.thread = kthread_create(wlan_logging_thread, NULL, "wlan_logging_thread"); if (IS_ERR(gwlan_logging.thread)) { pr_err("%s: Could not Create LogMsg Thread Controller", __func__); spin_lock_irqsave(&gwlan_logging.spin_lock, irq_flag); temp = gplog_msg; gplog_msg = NULL; gwlan_logging.pcur_node = NULL; spin_unlock_irqrestore(&gwlan_logging.spin_lock, irq_flag); vfree(temp); temp = NULL; return -ENOMEM; } wake_up_process(gwlan_logging.thread); gwlan_logging.is_active = true; nl_srv_register(ANI_NL_MSG_LOG, wlan_logging_proc_sock_rx_msg); //Broadcast SVC ready message to logging app/s running wlan_logging_srv_nl_ready_indication(); return 0; } int wlan_logging_flush_pkt_queue(void) { vos_pkt_t *pkt_queue_head; unsigned long flags; spin_lock_irqsave(&gwlan_logging.data_mgmt_pkt_lock, flags); if (NULL != gwlan_logging.data_mgmt_pkt_queue) { pkt_queue_head = gwlan_logging.data_mgmt_pkt_queue; gwlan_logging.data_mgmt_pkt_queue = NULL; gwlan_logging.pkt_drop_cnt = 0; gwlan_logging.data_mgmt_pkt_qcnt = 0; spin_unlock_irqrestore(&gwlan_logging.data_mgmt_pkt_lock, flags); vos_pkt_return_packet(pkt_queue_head); } else { spin_unlock_irqrestore(&gwlan_logging.data_mgmt_pkt_lock, flags); } spin_lock_irqsave(&gwlan_logging.fw_log_pkt_lock, flags); if (NULL != gwlan_logging.fw_log_pkt_queue) { pkt_queue_head = gwlan_logging.fw_log_pkt_queue; gwlan_logging.fw_log_pkt_queue = NULL; gwlan_logging.fw_log_pkt_drop_cnt = 0; gwlan_logging.fw_log_pkt_qcnt = 0; spin_unlock_irqrestore(&gwlan_logging.fw_log_pkt_lock, flags); vos_pkt_return_packet(pkt_queue_head); } else { spin_unlock_irqrestore(&gwlan_logging.fw_log_pkt_lock, flags); } spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); if (NULL != gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue) { pkt_queue_head = gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); vos_pkt_return_packet(pkt_queue_head); wlan_free_fwr_mem_dump_buffer(); } else { spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); } return 0; } int wlan_logging_sock_deactivate_svc(void) { unsigned long irq_flag; int i; struct log_msg *temp; if (!gplog_msg) return 0; nl_srv_unregister(ANI_NL_MSG_LOG, wlan_logging_proc_sock_rx_msg); clear_default_logtoapp_log_level(); gapp_pid = INVALID_PID; INIT_COMPLETION(gwlan_logging.shutdown_comp); wmb(); gwlan_logging.exit = true; gwlan_logging.is_active = false; vos_set_multicast_logging(0); wake_up_interruptible(&gwlan_logging.wait_queue); wait_for_completion(&gwlan_logging.shutdown_comp); spin_lock_irqsave(&gwlan_logging.spin_lock, irq_flag); temp = gplog_msg; gplog_msg = NULL; gwlan_logging.pcur_node = NULL; spin_unlock_irqrestore(&gwlan_logging.spin_lock, irq_flag); vfree(temp); temp = NULL; spin_lock_irqsave(&gwlan_logging.pkt_stats_lock, irq_flag); /* free allocated skb */ for (i = 0; i < gwlan_logging.pkt_stat_num_buf; i++) { if (pkt_stats_buffers && pkt_stats_buffers[i].skb) dev_kfree_skb(pkt_stats_buffers[i].skb); } if(pkt_stats_buffers) vos_mem_free(pkt_stats_buffers); pkt_stats_buffers = NULL; gwlan_logging.pkt_stats_pcur_node = NULL; gwlan_logging.pkt_stats_enabled = false; spin_unlock_irqrestore(&gwlan_logging.pkt_stats_lock, irq_flag); wlan_logging_flush_pkt_queue(); return 0; } int wlan_logging_sock_init_svc(void) { spin_lock_init(&gwlan_logging.spin_lock); spin_lock_init(&gwlan_logging.data_mgmt_pkt_lock); spin_lock_init(&gwlan_logging.fw_log_pkt_lock); spin_lock_init(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock); spin_lock_init(&gwlan_logging.pkt_stats_lock); gapp_pid = INVALID_PID; gwlan_logging.pcur_node = NULL; gwlan_logging.pkt_stats_pcur_node= NULL; wlan_init_log_completion(); return 0; } int wlan_logging_sock_deinit_svc(void) { gwlan_logging.pcur_node = NULL; gwlan_logging.pkt_stats_pcur_node = NULL; gapp_pid = INVALID_PID; wlan_deinit_log_completion(); return 0; } int wlan_queue_data_mgmt_pkt_for_app(vos_pkt_t *pPacket) { unsigned long flags; vos_pkt_t *next_pkt; vos_pkt_t *free_pkt; VOS_STATUS status = VOS_STATUS_E_FAILURE; spin_lock_irqsave(&gwlan_logging.data_mgmt_pkt_lock, flags); if (gwlan_logging.data_mgmt_pkt_qcnt >= LOGGER_MAX_DATA_MGMT_PKT_Q_LEN) { status = vos_pkt_walk_packet_chain( gwlan_logging.data_mgmt_pkt_queue, &next_pkt, TRUE); /*both "success" and "empty" are acceptable results*/ if (!((status == VOS_STATUS_SUCCESS) || (status == VOS_STATUS_E_EMPTY))) { ++gwlan_logging.pkt_drop_cnt; spin_unlock_irqrestore( &gwlan_logging.data_mgmt_pkt_lock, flags); pr_err("%s: Failure walking packet chain", __func__); /*keep returning pkts to avoid low resource cond*/ vos_pkt_return_packet(pPacket); return VOS_STATUS_E_FAILURE; } free_pkt = gwlan_logging.data_mgmt_pkt_queue; gwlan_logging.data_mgmt_pkt_queue = next_pkt; /*returning head of pkt queue. latest pkts are important*/ --gwlan_logging.data_mgmt_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.data_mgmt_pkt_lock, flags); vos_pkt_return_packet(free_pkt); } else { spin_unlock_irqrestore(&gwlan_logging.data_mgmt_pkt_lock, flags); } spin_lock_irqsave(&gwlan_logging.data_mgmt_pkt_lock, flags); if (gwlan_logging.data_mgmt_pkt_queue) { vos_pkt_chain_packet(gwlan_logging.data_mgmt_pkt_queue, pPacket, TRUE); } else { gwlan_logging.data_mgmt_pkt_queue = pPacket; } ++gwlan_logging.data_mgmt_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.data_mgmt_pkt_lock, flags); set_bit(LOGGER_MGMT_DATA_PKT_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); return VOS_STATUS_SUCCESS; } /** * wlan_logging_set_log_level() - Set the logging level * * This function is used to set the logging level of host debug messages * * Return: None */ void wlan_logging_set_log_level(void) { set_default_logtoapp_log_level(); } int wlan_queue_fw_log_pkt_for_app(vos_pkt_t *pPacket) { unsigned long flags; vos_pkt_t *next_pkt; vos_pkt_t *free_pkt; VOS_STATUS status = VOS_STATUS_E_FAILURE; spin_lock_irqsave(&gwlan_logging.fw_log_pkt_lock, flags); if (gwlan_logging.fw_log_pkt_qcnt >= LOGGER_MAX_FW_LOG_PKT_Q_LEN) { status = vos_pkt_walk_packet_chain( gwlan_logging.fw_log_pkt_queue, &next_pkt, TRUE); /*both "success" and "empty" are acceptable results*/ if (!((status == VOS_STATUS_SUCCESS) || (status == VOS_STATUS_E_EMPTY))) { ++gwlan_logging.fw_log_pkt_drop_cnt; spin_unlock_irqrestore( &gwlan_logging.fw_log_pkt_lock, flags); pr_err("%s: Failure walking packet chain", __func__); /*keep returning pkts to avoid low resource cond*/ vos_pkt_return_packet(pPacket); return VOS_STATUS_E_FAILURE; } free_pkt = gwlan_logging.fw_log_pkt_queue; gwlan_logging.fw_log_pkt_queue = next_pkt; /*returning head of pkt queue. latest pkts are important*/ --gwlan_logging.fw_log_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.fw_log_pkt_lock, flags); vos_pkt_return_packet(free_pkt); } else { spin_unlock_irqrestore(&gwlan_logging.fw_log_pkt_lock, flags); } spin_lock_irqsave(&gwlan_logging.fw_log_pkt_lock, flags); if (gwlan_logging.fw_log_pkt_queue) { vos_pkt_chain_packet(gwlan_logging.fw_log_pkt_queue, pPacket, TRUE); } else { gwlan_logging.fw_log_pkt_queue = pPacket; } ++gwlan_logging.fw_log_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.fw_log_pkt_lock, flags); set_bit(LOGGER_FW_LOG_PKT_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); return VOS_STATUS_SUCCESS; } int wlan_queue_fw_mem_dump_for_app(vos_pkt_t *pPacket) { unsigned long flags; vos_pkt_t *next_pkt; vos_pkt_t *free_pkt; VOS_STATUS status = VOS_STATUS_E_FAILURE; spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); if (gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_pkt_qcnt >= LOGGER_MAX_FW_MEM_DUMP_PKT_Q_LEN) { status = vos_pkt_walk_packet_chain( gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue, &next_pkt, TRUE); /*both "success" and "empty" are acceptable results*/ if (!((status == VOS_STATUS_SUCCESS) || (status == VOS_STATUS_E_EMPTY))) { spin_unlock_irqrestore( &gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); pr_err("%s: Failure walking packet chain", __func__); /*keep returning pkts to avoid low resource cond*/ vos_pkt_return_packet(pPacket); return VOS_STATUS_E_FAILURE; } free_pkt = gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue; gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue = next_pkt; /*returning head of pkt queue. latest pkts are important*/ --gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_pkt_qcnt; ++gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_pkt_drop_cnt ; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); pr_info("%s : fw mem_dump pkt cnt --> %d\n" ,__func__, gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_pkt_drop_cnt); vos_pkt_return_packet(free_pkt); } else { spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); } spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); if (gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue) { vos_pkt_chain_packet(gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue, pPacket, TRUE); } else { gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_queue = pPacket; } ++gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_pkt_qcnt; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); set_bit(LOGGER_FW_MEM_DUMP_PKT_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); return VOS_STATUS_SUCCESS; } int wlan_queue_logpkt_for_app(vos_pkt_t *pPacket, uint32 pkt_type) { VOS_STATUS status = VOS_STATUS_E_FAILURE; if (pPacket == NULL) { pr_err("%s: Null param", __func__); VOS_ASSERT(0); return VOS_STATUS_E_FAILURE; } if (gwlan_logging.is_active == false) { /*return all packets queued*/ wlan_logging_flush_pkt_queue(); /*return currently received pkt*/ vos_pkt_return_packet(pPacket); return VOS_STATUS_E_FAILURE; } switch (pkt_type) { case WLAN_MGMT_FRAME_LOGS: status = wlan_queue_data_mgmt_pkt_for_app(pPacket); break; case WLAN_FW_LOGS: status = wlan_queue_fw_log_pkt_for_app(pPacket); break; case WLAN_FW_MEMORY_DUMP: status = wlan_queue_fw_mem_dump_for_app(pPacket); break; default: pr_info("%s: Unknown pkt received %d", __func__, pkt_type); status = VOS_STATUS_E_INVAL; break; }; return status; } void wlan_process_done_indication(uint8 type, uint32 reason_code) { if (FALSE == sme_IsFeatureSupportedByFW(MEMORY_DUMP_SUPPORTED)) { if ((type == WLAN_FW_LOGS) && (wlan_is_log_report_in_progress() == TRUE)) { pr_info("%s: Setting LOGGER_FATAL_EVENT %d\n", __func__, reason_code); set_bit(LOGGER_FATAL_EVENT_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } return; } if ((type == WLAN_FW_LOGS) && reason_code && vos_isFatalEventEnabled() && vos_is_wlan_logging_enabled()) { if(wlan_is_log_report_in_progress() == TRUE) { pr_info("%s: Setting LOGGER_FATAL_EVENT %d\n", __func__, reason_code); set_bit(LOGGER_FATAL_EVENT_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } else { unsigned long flags; /* Drop FW initiated fatal event for * LIMIT_FW_FATAL_EVENT_MS if received for same reason. */ spin_lock_irqsave(&gwlan_logging.bug_report_lock, flags); if ((reason_code == gwlan_logging.log_complete.last_fw_bug_reason) && ((vos_timer_get_system_time() - gwlan_logging.log_complete.last_fw_bug_timestamp) < LIMIT_FW_FATAL_EVENT_MS)) { spin_unlock_irqrestore( &gwlan_logging.bug_report_lock, flags); pr_debug_ratelimited( "%s: Ignoring Fatal event from firmware for reason %d\n", __func__, reason_code); return; } gwlan_logging.log_complete.last_fw_bug_reason = reason_code; gwlan_logging.log_complete.last_fw_bug_timestamp = vos_timer_get_system_time(); spin_unlock_irqrestore(&gwlan_logging.bug_report_lock, flags); /*Firmware Initiated*/ pr_info("%s : FW triggered Fatal Event, reason_code : %d\n", __func__, reason_code); wlan_set_log_completion(WLAN_LOG_TYPE_FATAL, WLAN_LOG_INDICATOR_FIRMWARE, reason_code); set_bit(LOGGER_FATAL_EVENT_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } } if(type == WLAN_FW_MEMORY_DUMP && vos_is_wlan_logging_enabled()) { pr_info("%s: Setting FW MEM DUMP LOGGER event\n", __func__); set_bit(LOGGER_FW_MEM_DUMP_PKT_POST_DONE, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } } /** * wlan_flush_host_logs_for_fatal() -flush host logs and send * fatal event to upper layer. */ void wlan_flush_host_logs_for_fatal() { unsigned long flags; if (wlan_is_log_report_in_progress()) { pr_info("%s:flush all host logs Setting HOST_LOG_POST\n", __func__); spin_lock_irqsave(&gwlan_logging.spin_lock, flags); wlan_queue_logmsg_for_app(); spin_unlock_irqrestore(&gwlan_logging.spin_lock, flags); set_bit(HOST_LOG_POST, &gwlan_logging.event_flag); wake_up_interruptible(&gwlan_logging.wait_queue); } } /** * wlan_is_logger_thread()- Check if threadid is * of logger thread * * @threadId: passed threadid * * This function is called to check if threadid is * of logger thread. * * Return: true if threadid is of logger thread. */ bool wlan_is_logger_thread(int threadId) { return ((gwlan_logging.thread) && (threadId == gwlan_logging.thread->pid)); } int wlan_fwr_mem_dump_buffer_allocation(void) { /*Allocate the dump memory as reported by fw. or if feature not supported just report to the user */ if(gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size <= 0) { pr_err("%s: fw_mem_dump_req not supported by firmware", __func__); return -EFAULT; } gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc = (uint8 *)vos_mem_vmalloc(gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size); gwlan_logging.fw_mem_dump_ctx.fw_dump_current_loc = gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc; if(NULL == gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc) { pr_err("%s: fw_mem_dump_req alloc failed for size %d bytes", __func__,gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size); return -ENOMEM; } vos_mem_zero(gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc,gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size); return 0; } /*set the current fw mem dump state*/ void wlan_set_fwr_mem_dump_state(enum FW_MEM_DUMP_STATE fw_mem_dump_state) { unsigned long flags; spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status = fw_mem_dump_state; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); } /*check for new request validity and free memory if present from previous request */ bool wlan_fwr_mem_dump_test_and_set_write_allowed_bit(){ unsigned long flags; bool ret = false; bool write_done = false; spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); if(gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status == FW_MEM_DUMP_IDLE){ ret = true; gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status = FW_MEM_DUMP_WRITE_IN_PROGRESS; } else if(gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status == FW_MEM_DUMP_WRITE_DONE){ ret = true; write_done = true; gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status = FW_MEM_DUMP_WRITE_IN_PROGRESS; } spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); pr_info("%s:fw mem dump state --> %d ", __func__,gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status); if(write_done) wlan_free_fwr_mem_dump_buffer(); return ret; } bool wlan_fwr_mem_dump_test_and_set_read_allowed_bit(){ unsigned long flags; bool ret=false; spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); if(gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status == FW_MEM_DUMP_WRITE_DONE || gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status == FW_MEM_DUMP_READ_IN_PROGRESS ){ ret = true; gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status = FW_MEM_DUMP_READ_IN_PROGRESS; } spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); //pr_info("%s:fw mem dump state --> %d ", __func__,gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_status); return ret; } size_t wlan_fwr_mem_dump_fsread_handler(char __user *buf, size_t count, loff_t *pos,loff_t* bytes_left) { if (buf == NULL || gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc == NULL) { pr_err("%s : start loc : %pK buf : %pK ",__func__,gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc,buf); return 0; } if (*pos < 0) { pr_err("Invalid start offset for memdump read"); return 0; } else if (*pos >= gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size || !count) { pr_err("No more data to copy"); return 0; } else if (count > gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size - *pos) { count = gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size - *pos; } if (copy_to_user(buf, gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc, count)) { pr_err("%s copy to user space failed",__func__); return 0; } /* offset(pos) should be updated here based on the copy done*/ *pos += count; *bytes_left = gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size - *pos; return count; } void wlan_set_svc_fw_mem_dump_req_cb (void * fw_mem_dump_req_cb, void * fw_mem_dump_req_cb_arg) { unsigned long flags; spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); gwlan_logging.fw_mem_dump_ctx.svc_fw_mem_dump_req_cb = fw_mem_dump_req_cb; gwlan_logging.fw_mem_dump_ctx.svc_fw_mem_dump_req_cb_arg = fw_mem_dump_req_cb_arg; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); } void wlan_free_fwr_mem_dump_buffer (void ) { unsigned long flags; void * tmp = NULL; spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); tmp = gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc; gwlan_logging.fw_mem_dump_ctx.fw_dump_start_loc = NULL; gwlan_logging.fw_mem_dump_ctx.fw_dump_current_loc = NULL; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); // Don't set fw_dump_max_size to 0, only free the buffera if(tmp != NULL) vos_mem_vfree((void *)tmp); } void wlan_store_fwr_mem_dump_size(uint32 dump_size) { unsigned long flags; spin_lock_irqsave(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); //Store the dump size gwlan_logging.fw_mem_dump_ctx.fw_dump_max_size = dump_size; spin_unlock_irqrestore(&gwlan_logging.fw_mem_dump_ctx.fw_mem_dump_lock, flags); } #ifdef FEATURE_WLAN_DIAG_SUPPORT /** * wlan_report_log_completion() - Report bug report completion to userspace * @is_fatal: Type of event, fatal or not * @indicator: Source of bug report, framework/host/firmware * @reason_code: Reason for triggering bug report * * This function is used to report the bug report completion to userspace * * Return: None */ void wlan_report_log_completion(uint32_t is_fatal, uint32_t indicator, uint32_t reason_code) { WLAN_VOS_DIAG_EVENT_DEF(wlan_diag_event, struct vos_event_wlan_log_complete); wlan_diag_event.is_fatal = is_fatal; wlan_diag_event.indicator = indicator; wlan_diag_event.reason_code = reason_code; wlan_diag_event.reserved = 0; WLAN_VOS_DIAG_EVENT_REPORT(&wlan_diag_event, EVENT_WLAN_LOG_COMPLETE); } #endif #endif /* WLAN_LOGGING_SOCK_SVC_ENABLE */
the_stack_data/31346.c
#include <stdio.h> #include <stdbool.h> int main() { int age=18; if(!(age>17))//mean !(true) = false >>> oposite { printf("This is adult \n"); } else { printf("This is not adult \n"); } double money=30000; bool isGraduated=true; if(age>17 && money>25000 || isGraduated)//mean !(true) = false >>> oposite { printf("This is rich \n"); } else { printf("This is not rich \n"); } return 0; }
the_stack_data/247018271.c
//===-- CBackend.cpp - Library for converting LLVM code to C --------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This code tests to see that the CBE will properly use the address-of value // (&) variable and and return the value-at address (*) variable from integer // 'num'. *TW // //===----------------------------------------------------------------------===// int main() { int *ptr; int num = 6; ptr = &num; int deref = *ptr; return deref; }
the_stack_data/32950304.c
/** * \file * \brief Debug system calls, specific for x86_64, user-side */ /* * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich. * All rights reserved. * * This file is distributed under the terms in the attached LICENSE file. * If you do not find this file, copies can be found by writing to: * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. */ // None
the_stack_data/82949438.c
/* * @explain: Copyright (c) 2020 WEI.ZHOU. All rights reserved. * The following code is only used for learning and communication, not for * illegal and commercial use. If the code is used, no consent is required, but * the author has nothing to do with any problems and consequences. * * In case of code problems, feedback can be made through the following email * address. <[email protected]> * * @Description: * @Author: WEI.ZHOU * @Date: 2020-10-24 10:31:52 * @Version: V1.0 * @LastEditTime: 2020-10-24 11:23:34 * @LastEditors: WEI.ZHOU * @Others: */ #include <stdio.h> int main() { float c; c = (5.0/9); printf("%f",c); return 0; }
the_stack_data/54825287.c
/**************************************************************************** * * Copyright (c) 2013-2015 PX4 Development Team. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. Neither the name PX4 nor the names of its contributors may be * used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************/ /** * @file simulator_params.c * * Parameters of software in the loop * * @author Mohamed Abdelkader <[email protected]> */
the_stack_data/29824005.c
#include <stdio.h> #include <string.h> int main(){ char mat[200][100]; strcpy(mat[0], "paulo"); printf("%s", mat[0]); } //https://pt.stackoverflow.com/q/307975/101
the_stack_data/89200890.c
#include <stdio.h> #include <unistd.h> #include <sys/wait.h> #include <sys/mman.h> #include <stdlib.h> #include <sys/stat.h> #include <fcntl.h> #define NUM_WORKERS 3 static int *glob_var; void make_child() { int fork_result = fork(); if(fork_result == -1) { perror("fork failure"); exit(1); } if(fork_result > 0) { return; } printf("worker process (pid %d) started\n", getpid()); signal(SIGCHLD, SIG_IGN); while(1) { fork_result = fork(); if(fork_result == -1) { perror("fork failure"); exit(1); } if(fork_result > 0) { int status; wait(&status); if(WEXITSTATUS(status) == 99) { printf("task.bin crashed with exit 99. worker (pid %d) aborting\n", getpid()); exit(0); } *glob_var = *glob_var + 1; continue; } execl("./task.bin", "./task.bin", NULL); perror("exec failure"); exit(1); } printf("bad place\n"); } void child_died() { printf("signal handler\n"); make_child(); } int main(int argc, char** argv) { printf("boss process (pid %d) started\n", getpid()); signal(SIGCHLD, child_died); glob_var = mmap(NULL, sizeof *glob_var, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); *glob_var = 0; int old_glob = 0; for(int i = 0; i < NUM_WORKERS; i++) { make_child(); } while(1) { if(*glob_var != old_glob) { old_glob++; printf("%d tasks finished\n", old_glob); } } }
the_stack_data/3550.c
#include <stdio.h> int main() { int arr1[30], arr2[30], i, num; printf("\nEnter no of elements :"); scanf("%d", &num); //Accepting values into Array printf("\nEnter the values :"); for (i = 0; i < num; i++) { scanf("%d", &arr1[i]); } /* Copying data from array 'a' to array 'b */ for (i = 0; i < num; i++) { arr2[i] = arr1[i]; } //Printing of all elements of array printf("The copied array is :"); for (i = 0; i < num; i++) printf("\narr2[%d] = %d", i, arr2[i]); return (0); }
the_stack_data/70451178.c
/* Calling bose(n) generates a network * to sort n items. See R. C. Bose & R. J. Nelson, * "A Sorting Problem", JACM Vol. 9, Pp. 282-296. */ #include <stdio.h> P(int i, int j) { /* print out in 0 based notation */ printf("swap(%d, %d);\n", i-1, j-1); } void Pbracket(int i, /* value of first element in sequence 1 */ int x, /* length of sequence 1 */ int j, /* value of first element in sequence 2 */ int y) /* length of sequence 2 */ { int a, b; if(x == 1 && y == 1) P(i, j); /* 1 comparison sorts 2 items */ else if(x == 1 && y == 2) { /* 2 comparisons inserts an item into an * already sorted sequence of length 2. */ P(i, (j + 1)); P(i, j); } else if(x == 2 && y == 1) { /* As above, but inserting j */ P(i, j); P((i + 1), j); } else { /* Recurse on shorter sequences, attempting * to make the length of one subsequence odd * and the length of the other even. If we * can do this, we eventually merge the two. */ a = x/2; b = (x & 1) ? (y/2) : ((y + 1)/2); Pbracket(i, a, j, b); Pbracket((i + a), (x - a), (j + b), (y - b)); Pbracket((i + a), (x - a), j, b); } } void Pstar(int i, /* value of first element in sequence */ int m) /* length of sequence */ { int a; if(m > 1) { /* Partition into 2 shorter sequences, * generate a sorting method for each, * and merge the two sub-networks. */ a = m/2; Pstar(i, a); Pstar((i + a), (m - a)); Pbracket(i, a, (i + a), (m - a)); } } void bose(int n) { Pstar(1, n); /* sort the sequence {X1,...,Xn} */ } int main(int argc, char *argv[]) { if (argc < 2) { printf("Usage:\n"); printf("\t bose-nelson <n>\n"); printf("\t\twhere n is the number of items to sort\n"); return(-1); } int n = atoi(argv[1]); bose(n); return 0; } /* End of File */
the_stack_data/968609.c
/* * isotprecv.c * * Copyright (c) 2008 Volkswagen Group Electronic Research * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Volkswagen nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * Alternatively, provided that this notice is retained in full, this * software may be distributed under the terms of the GNU General * Public License ("GPL") version 2, in which case the provisions of the * GPL apply INSTEAD OF those given above. * * The provided data structures and external interfaces from this code * are not restricted to be used by modules with a GPL compatible license. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. * * Send feedback to <[email protected]> * */ #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <libgen.h> #include <net/if.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <linux/can.h> #include <linux/can/isotp.h> #define NO_CAN_ID 0xFFFFFFFFU void print_usage(char *prg) { fprintf(stderr, "\nUsage: %s [options] <CAN interface>\n", prg); fprintf(stderr, "Options: -s <can_id> (source can_id. Use 8 digits for extended IDs)\n"); fprintf(stderr, " -d <can_id> (destination can_id. Use 8 digits for extended IDs)\n"); fprintf(stderr, " -x <addr> (extended addressing mode.)\n"); fprintf(stderr, " -p <byte> (set and enable padding byte)\n"); fprintf(stderr, " -P <mode> (check padding in SF/CF. (l)ength (c)ontent (a)ll)\n"); fprintf(stderr, " -b <bs> (blocksize. 0 = off)\n"); fprintf(stderr, " -m <val> (STmin in ms/ns. See spec.)\n"); fprintf(stderr, " -f <time ns> (force rx stmin value in nanosecs)\n"); fprintf(stderr, " -w <num> (max. wait frame transmissions.)\n"); fprintf(stderr, " -l (loop: do not exit after pdu receiption.)\n"); fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n"); fprintf(stderr, "The pdu data is written on STDOUT in space separated ASCII hex values.\n"); fprintf(stderr, "\n"); } int main(int argc, char **argv) { int s; struct sockaddr_can addr; struct ifreq ifr; static struct can_isotp_options opts; static struct can_isotp_fc_options fcopts; int opt, i; extern int optind, opterr, optopt; __u32 force_rx_stmin = 0; int loop = 0; unsigned char msg[4096]; int nbytes; addr.can_addr.tp.tx_id = addr.can_addr.tp.rx_id = NO_CAN_ID; while ((opt = getopt(argc, argv, "s:d:x:p:P:b:m:w:f:l?")) != -1) { switch (opt) { case 's': addr.can_addr.tp.tx_id = strtoul(optarg, (char **)NULL, 16); if (strlen(optarg) > 7) addr.can_addr.tp.tx_id |= CAN_EFF_FLAG; break; case 'd': addr.can_addr.tp.rx_id = strtoul(optarg, (char **)NULL, 16); if (strlen(optarg) > 7) addr.can_addr.tp.rx_id |= CAN_EFF_FLAG; break; case 'x': opts.flags |= CAN_ISOTP_EXTEND_ADDR; opts.ext_address = strtoul(optarg, (char **)NULL, 16) & 0xFF; break; case 'p': opts.flags |= CAN_ISOTP_RX_PADDING; opts.rxpad_content = strtoul(optarg, (char **)NULL, 16) & 0xFF; break; case 'P': if (optarg[0] == 'l') opts.flags |= CAN_ISOTP_CHK_PAD_LEN; else if (optarg[0] == 'c') opts.flags |= CAN_ISOTP_CHK_PAD_DATA; else if (optarg[0] == 'a') opts.flags |= (CAN_ISOTP_CHK_PAD_DATA | CAN_ISOTP_CHK_PAD_DATA); else { printf("unknown padding check option '%c'.\n", optarg[0]); print_usage(basename(argv[0])); exit(0); } break; case 'b': fcopts.bs = strtoul(optarg, (char **)NULL, 16) & 0xFF; break; case 'm': fcopts.stmin = strtoul(optarg, (char **)NULL, 16) & 0xFF; break; case 'w': fcopts.wftmax = strtoul(optarg, (char **)NULL, 16) & 0xFF; break; case 'f': opts.flags |= CAN_ISOTP_FORCE_RXSTMIN; force_rx_stmin = strtoul(optarg, (char **)NULL, 10); break; case 'l': loop = 1; break; case '?': print_usage(basename(argv[0])); exit(0); break; default: fprintf(stderr, "Unknown option %c\n", opt); print_usage(basename(argv[0])); exit(1); break; } } if ((argc - optind != 1) || (addr.can_addr.tp.tx_id == NO_CAN_ID) || (addr.can_addr.tp.rx_id == NO_CAN_ID)) { print_usage(basename(argv[0])); exit(1); } if ((s = socket(PF_CAN, SOCK_DGRAM, CAN_ISOTP)) < 0) { perror("socket"); exit(1); } setsockopt(s, SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &opts, sizeof(opts)); setsockopt(s, SOL_CAN_ISOTP, CAN_ISOTP_RECV_FC, &fcopts, sizeof(fcopts)); if (opts.flags & CAN_ISOTP_FORCE_RXSTMIN) setsockopt(s, SOL_CAN_ISOTP, CAN_ISOTP_RX_STMIN, &force_rx_stmin, sizeof(force_rx_stmin)); addr.can_family = AF_CAN; strcpy(ifr.ifr_name, argv[optind]); ioctl(s, SIOCGIFINDEX, &ifr); addr.can_ifindex = ifr.ifr_ifindex; if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) { perror("bind"); close(s); exit(1); } do { nbytes = read(s, msg, 4096); if (nbytes > 0 && nbytes < 4096) for (i=0; i < nbytes; i++) printf("%02X ", msg[i]); printf("\n"); } while (loop); close(s); return 0; }
the_stack_data/14953.c
/* Dereference of a pointer stored inside an array */ int main() { int* pointer = 0; int* a[1] = {pointer}; int value = *a[0]; }
the_stack_data/50137173.c
#include<stdio.h> #include<stdlib.h> int sift_arr(int *arr, int arr_len, int i, int shet) //Ïèðîìèäàëüíàÿ ñîðòèðîâêà { int max_elem= arr_len,tmp; for (;;) { if ((2 * i > arr_len)||(max_elem==0)) { break; } if (2 * i == arr_len) { max_elem = arr_len; } else { shet++; if (arr[2 * i] > arr[2 * i + 1]) { max_elem = 2 * i; } else if (arr[2 * i] <= arr[2 * i + 1]) { shet++; max_elem = 2 * i + 1; } } shet++; if (arr[i] < arr[max_elem]) { shet++; tmp = arr[i]; arr[i] = arr[max_elem]; arr[max_elem] = tmp; } i = max_elem; } return shet; } int heap_sort(int *arr, int arr_len) { int i, shet=0,tmp; for (i = (arr_len) / 2; i >= 0; i--) { sift_arr(arr, arr_len, i, shet); } while(arr_len>0) { shet++; tmp = arr[0]; arr[0]=arr[arr_len]; arr[arr_len] = tmp; arr_len--; sift_arr(arr, arr_len, 0, shet); } return shet; } int main() { int n,*arr; scanf("%d", &n); arr = (int*)malloc(n * sizeof(int)); for (int i = 0; i < n; ++i) { scanf("%d", &arr[i]); } heap_sort(arr, n-1); for (int i = 0; i < n-1; ++i) { printf("%d ", arr[i]); } printf("%d\n", arr[n-1]); free(arr); return 0; }
the_stack_data/122016491.c
typedef unsigned char undefined; typedef unsigned char byte; typedef unsigned int dword; typedef unsigned char uchar; typedef unsigned short word; typedef struct Elf32_Shdr Elf32_Shdr, *PElf32_Shdr; typedef enum Elf_SectionHeaderType_RISCV { SHT_ANDROID_REL=1610612737, SHT_ANDROID_RELA=1610612738, SHT_CHECKSUM=1879048184, SHT_DYNAMIC=6, SHT_DYNSYM=11, SHT_FINI_ARRAY=15, SHT_GNU_ATTRIBUTES=1879048181, SHT_GNU_HASH=1879048182, SHT_GNU_LIBLIST=1879048183, SHT_GNU_verdef=1879048189, SHT_GNU_verneed=1879048190, SHT_GNU_versym=1879048191, SHT_GROUP=17, SHT_HASH=5, SHT_INIT_ARRAY=14, SHT_NOBITS=8, SHT_NOTE=7, SHT_NULL=0, SHT_PREINIT_ARRAY=16, SHT_PROGBITS=1, SHT_REL=9, SHT_RELA=4, SHT_SHLIB=10, SHT_STRTAB=3, SHT_SUNW_COMDAT=1879048187, SHT_SUNW_move=1879048186, SHT_SUNW_syminfo=1879048188, SHT_SYMTAB=2, SHT_SYMTAB_SHNDX=18 } Elf_SectionHeaderType_RISCV; struct Elf32_Shdr { dword sh_name; enum Elf_SectionHeaderType_RISCV sh_type; dword sh_flags; dword sh_addr; dword sh_offset; dword sh_size; dword sh_link; dword sh_info; dword sh_addralign; dword sh_entsize; }; typedef struct Elf32_Rela Elf32_Rela, *PElf32_Rela; struct Elf32_Rela { dword r_offset; // location to apply the relocation action dword r_info; // the symbol table index and the type of relocation dword r_addend; // a constant addend used to compute the relocatable field value }; typedef struct Elf32_Sym Elf32_Sym, *PElf32_Sym; struct Elf32_Sym { dword st_name; dword st_value; dword st_size; byte st_info; byte st_other; word st_shndx; }; typedef struct Elf32_Ehdr Elf32_Ehdr, *PElf32_Ehdr; struct Elf32_Ehdr { byte e_ident_magic_num; char e_ident_magic_str[3]; byte e_ident_class; byte e_ident_data; byte e_ident_version; byte e_ident_osabi; byte e_ident_abiversion; byte e_ident_pad[7]; word e_type; word e_machine; dword e_version; dword e_entry; dword e_phoff; dword e_shoff; dword e_flags; word e_ehsize; word e_phentsize; word e_phnum; word e_shentsize; word e_shnum; word e_shstrndx; };
the_stack_data/82493.c
int sum(int a, int b) { int c; c = a + b; return c; } int main () { int result; result = sum(5, 4); return 0; }
the_stack_data/107952762.c
/* * test #define * Liao 12/1/2010 */ #include <stdio.h> #ifdef _OPENMP #include <omp.h> #endif #define P 4 void foo(int iend, int ist) { int i; i= i+P; #pragma omp parallel { #pragma omp single printf ("Using %d threads.\n",omp_get_num_threads()); #pragma omp for nowait schedule(static,P) for (i=iend;i>=ist;i--) { printf("Iteration %d is carried out by thread %d\n",i, omp_get_thread_num()); } } }
the_stack_data/162643960.c
//===--- folding.c --- Test Cases for Bit Accurate Types ------------------===//// // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This is used to test constant folding optimization. // //===----------------------------------------------------------------------===// #include <stdio.h> typedef int __attribute__ ((bitwidth(7))) int7; typedef unsigned int __attribute__ ((bitwidth(7))) uint7; typedef int __attribute__ ((bitwidth(15))) int15; const int7 myConst = 1; const int15 myConst2 = 0x7fff; int main() { int7 x; int7 y; int15 z; uint7 u; x = myConst << 3; // constant 8 y = x + myConst; // constant 9 if(y -x != 1) printf("error1: x = %d, y = %d\n", x, y); x = myConst << 7; // constant 0 if(y -x != 9) printf("error2: x = %d, y = %d\n", x, y); z = (int15) y; z &= myConst2; if(z != 0x9) printf("error3: x = %d, y = %d\n", x, y); u = 0x7f; u = u + (uint7)myConst; if(u != 0) printf("error4: x = %d, y = %d\n", x, y); return 0; }
the_stack_data/125960.c
int main(void) { int x = 18; return x; }
the_stack_data/73574840.c
/* The Computer Language Benchmarks Game * http://benchmarksgame.alioth.debian.org/ * * Contributed by Sebastien Loisel * Modified by Alex Belits */ #include <stdio.h> #include <stdlib.h> #include <math.h> double *A_global=NULL; int N_global; double eval_A(int i, int j) { return 1.0/((i+j)*(i+j+1)/2+i+1); } int prepare_A(int N) { int i,j; N_global=N; A_global=(double*)malloc(N*N*sizeof(double)); if(A_global==NULL) return -1; for(i=0;i<N;i++) { for(j=0;j<N;j++) { A_global[i*N+j]=eval_A(i,j); } } return 0; } double get_A(int i, int j) { return A_global[i*N_global+j]; } void eval_A_times_u(int N, const double u[], double Au[]) { int i,j,n2; double t0,t1; n2=N&~1; for(i=0;i<n2;i+=2) { t0=0; t1=0; for(j=0;j<N;j++) { t0+=get_A(i,j)*u[j]; t1+=get_A(i+1,j)*u[j]; } Au[i]=t0; Au[i+1]=t1; } if(i!=N) { t0=0; for(j=0;j<N;j++) { t0+=get_A(i,j)*u[j]; } Au[i]=t0; } } void eval_At_times_u(int N, const double u[], double Au[]) { int i,j,n4; double t0,t1,t2,t3; n4=N&~3; for(i=0;i<n4;i+=4) { t0=0; t1=0; t2=0; t3=0; for(j=0;j<N;j++) { t0+=get_A(j,i)*u[j]; t1+=get_A(j,i+1)*u[j]; t2+=get_A(j,i+2)*u[j]; t3+=get_A(j,i+3)*u[j]; } Au[i]=t0; Au[i+1]=t1; Au[i+2]=t2; Au[i+3]=t3; } for(;i<N;i++) { t0=0; for(j=0;j<N;j++) { t0+=get_A(j,i)*u[j]; } Au[i]=t0; } } void eval_AtA_times_u(int N, const double u[], double AtAu[]) { double v[N]; eval_A_times_u(N,u,v); eval_At_times_u(N,v,AtAu); } int main(int argc, char *argv[]) { int i; int N = ((argc == 2) ? atoi(argv[1]) : 2000); double u[N],v[N],vBv,vv; if(prepare_A(N)){ printf("Insufficient memory\n"); return 1; } for(i=0;i<N;i++) u[i]=1; for(i=0;i<10;i++) { eval_AtA_times_u(N,u,v); eval_AtA_times_u(N,v,u); } vBv=vv=0; for(i=0;i<N;i++) { vBv+=u[i]*v[i]; vv+=v[i]*v[i]; } printf("%0.9f\n",sqrt(vBv/vv)); free(A_global); return 0; }
the_stack_data/104827212.c
extern int getone(); #include <assert.h> int main(int argc, char** argv) { assert(getone()==1); } int altmain() { assert(getone()==0); }
the_stack_data/45693.c
static void *self(void *p){ return p; } int f() { struct { int i; } s, *sp; int *ip = &s.i; s.i = 1; sp = self(&s); *ip = 0; return sp->i+1; } main() { if (f () != 1) abort (); else exit (0); }
the_stack_data/92327902.c
#include <stdio.h> int main() { printf("hello world!\n"); return 0; }
the_stack_data/225143402.c
// RUN: %clang_cc1 -triple arm64_32-apple-ios7.0 -target-abi darwinpcs -emit-llvm -o - -O1 -ffreestanding %s | FileCheck %s #include <stdarg.h> typedef struct { int a; } OneInt; // No realignment should be needed here: slot size is 4 bytes. int test_int(OneInt input, va_list *mylist) { // CHECK-LABEL: define{{.*}} i32 @test_int(i32 %input // CHECK: [[START:%.*]] = load i8*, i8** %mylist // CHECK: [[NEXT:%.*]] = getelementptr inbounds i8, i8* [[START]], i32 4 // CHECK: store i8* [[NEXT]], i8** %mylist // CHECK: [[ADDR_I32:%.*]] = bitcast i8* [[START]] to i32* // CHECK: [[RES:%.*]] = load i32, i32* [[ADDR_I32]] // CHECK: ret i32 [[RES]] return va_arg(*mylist, OneInt).a; } typedef struct { long long a; } OneLongLong; // Minimum slot size is 4 bytes, so address needs rounding up to multiple of 8. long long test_longlong(OneLongLong input, va_list *mylist) { // CHECK-LABEL: define{{.*}} i64 @test_longlong(i64 %input // CHECK: [[STARTPTR:%.*]] = load i8*, i8** %mylist // CHECK: [[START:%.*]] = ptrtoint i8* [[STARTPTR]] to i32 // CHECK: [[ALIGN_TMP:%.*]] = add i32 [[START]], 7 // CHECK: [[ALIGNED:%.*]] = and i32 [[ALIGN_TMP]], -8 // CHECK: [[ALIGNED_ADDR:%.*]] = inttoptr i32 [[ALIGNED]] to i8* // CHECK: [[NEXT:%.*]] = getelementptr inbounds i8, i8* [[ALIGNED_ADDR]], i32 8 // CHECK: store i8* [[NEXT]], i8** %mylist // CHECK: [[ADDR_STRUCT:%.*]] = inttoptr i32 [[ALIGNED]] to %struct.OneLongLong* // CHECK: [[ADDR_I64:%.*]] = getelementptr inbounds %struct.OneLongLong, %struct.OneLongLong* [[ADDR_STRUCT]], i32 0, i32 0 // CHECK: [[RES:%.*]] = load i64, i64* [[ADDR_I64]] // CHECK: ret i64 [[RES]] return va_arg(*mylist, OneLongLong).a; } typedef struct { float arr[4]; } HFA; // HFAs take priority over passing large structs indirectly. float test_hfa(va_list *mylist) { // CHECK-LABEL: define{{.*}} float @test_hfa // CHECK: [[START:%.*]] = load i8*, i8** %mylist // CHECK: [[NEXT:%.*]] = getelementptr inbounds i8, i8* [[START]], i32 16 // CHECK: store i8* [[NEXT]], i8** %mylist // CHECK: [[ADDR_FLOAT:%.*]] = bitcast i8* [[START]] to float* // CHECK: [[RES:%.*]] = load float, float* [[ADDR_FLOAT]] // CHECK: ret float [[RES]] return va_arg(*mylist, HFA).arr[0]; } // armv7k does not return HFAs normally for variadic functions, so we must match // that. HFA test_hfa_return(int n, ...) { // CHECK-LABEL: define{{.*}} [2 x i64] @test_hfa_return HFA h = {0}; return h; } typedef struct { long long a, b; char c; } BigStruct; // Structs bigger than 16 bytes are passed indirectly: a pointer is placed on // the stack. long long test_bigstruct(BigStruct input, va_list *mylist) { // CHECK-LABEL: define{{.*}} i64 @test_bigstruct(%struct.BigStruct* // CHECK: [[START:%.*]] = load i8*, i8** %mylist // CHECK: [[NEXT:%.*]] = getelementptr inbounds i8, i8* [[START]], i32 4 // CHECK: store i8* [[NEXT]], i8** %mylist // CHECK: [[INT_PTR:%.*]] = bitcast i8* [[START]] to %struct.BigStruct** // CHECK: [[ADDR:%.*]] = load %struct.BigStruct*, %struct.BigStruct** [[INT_PTR]] // CHECK: [[ADDR_I64:%.*]] = getelementptr inbounds %struct.BigStruct, %struct.BigStruct* [[ADDR]], i32 0, i32 0 // CHECK: [[RES:%.*]] = load i64, i64* [[ADDR_I64]] // CHECK: ret i64 [[RES]] return va_arg(*mylist, BigStruct).a; } typedef struct { short arr[3]; } ThreeShorts; // Slot sizes are 4-bytes on arm64_32, so structs with less than 32-bit // alignment must be passed via "[N x i32]" to be correctly allocated in the // backend. short test_threeshorts(ThreeShorts input, va_list *mylist) { // CHECK-LABEL: define{{.*}} signext i16 @test_threeshorts([2 x i32] %input // CHECK: [[START:%.*]] = load i8*, i8** %mylist // CHECK: [[NEXT:%.*]] = getelementptr inbounds i8, i8* [[START]], i32 8 // CHECK: store i8* [[NEXT]], i8** %mylist // CHECK: [[ADDR_I32:%.*]] = bitcast i8* [[START]] to i16* // CHECK: [[RES:%.*]] = load i16, i16* [[ADDR_I32]] // CHECK: ret i16 [[RES]] return va_arg(*mylist, ThreeShorts).arr[0]; }
the_stack_data/198581880.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strncmp.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: mmartin <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2013/11/20 15:53:25 by mmartin #+# #+# */ /* Updated: 2013/12/06 17:30:58 by mmartin ### ########.fr */ /* */ /* ************************************************************************** */ #include <string.h> int ft_strncmp(const char *s1, const char *s2, size_t n) { int i; i = 0; while (n > 0) { if (s1[i] != s2[i]) return ((unsigned char)s1[i] - (unsigned char)s2[i]); else if (s1[i] == '\0') return (0); i++; n--; } return (0); }
the_stack_data/92328914.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2010-2017 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <signal.h> #include <assert.h> #include <string.h> #include <unistd.h> #ifndef SA_SIGINFO # error "SA_SIGINFO is required for this test" #endif static int callme (void) { return 42; } static int pass (void) { return 1; } static int fail (void) { return 1; } static void handler (int sig, siginfo_t *siginfo, void *context) { assert (sig == SIGUSR1); assert (siginfo->si_signo == SIGUSR1); if (siginfo->si_pid == getpid ()) pass (); else fail (); } int main (void) { struct sigaction sa; int i; callme (); memset (&sa, 0, sizeof (sa)); sa.sa_sigaction = handler; sa.sa_flags = SA_SIGINFO; i = sigemptyset (&sa.sa_mask); assert (i == 0); i = sigaction (SIGUSR1, &sa, NULL); assert (i == 0); i = raise (SIGUSR1); assert (i == 0); sleep (600); return 0; }
the_stack_data/11075488.c
// Fig. 10.18: fig10_18.c // Using an enumeration #include <stdio.h> // enumeration constants represent months of the year enum months { JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC }; int main(void) { // initialize array of pointers const char *monthName[] = { "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; // loop through months for (enum months month = JAN; month <= DEC; ++month) { printf("%2d%11s\n", month, monthName[month]); } } /************************************************************************** * (C) Copyright 1992-2015 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * *************************************************************************/
the_stack_data/181392843.c
int recursiveTailCall(int data) { f1(data); return recursiveTailCall(data); }
the_stack_data/104828204.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, R. Hrbacek, Z. Vasicek and L. Sekanina, "EvoApprox8b: Library of approximate adders and multipliers for circuit design and benchmarking of approximation methods". Design, Automation & Test in Europe Conference & Exhibition (DATE), 2017, Lausanne, 2017, pp. 258-261. doi: 10.23919/DATE.2017.7926993 * This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and mse parameters ***/ // MAE% = 0.0015 % // MAE = 1.0 // WCE% = 0.0046 % // WCE = 3.0 // WCRE% = 100.00 % // EP% = 64.06 % // MRE% = 0.052 % // MSE = 1.9 // PDK45_PWR = 0.386 mW // PDK45_AREA = 676.3 um2 // PDK45_DELAY = 1.42 ns #include <stdint.h> #include <stdlib.h> uint64_t mul8u_2P7(const uint64_t B,const uint64_t A) { uint64_t O, dout_18, dout_19, dout_20, dout_21, dout_22, dout_23, dout_25, dout_26, dout_27, dout_28, dout_29, dout_30, dout_31, dout_33, dout_34, dout_35, dout_36, dout_37, dout_38, dout_39, dout_40, dout_41, dout_42, dout_43, dout_44, dout_45, dout_46, dout_47, dout_48, dout_49, dout_50, dout_51, dout_52, dout_53, dout_54, dout_55, dout_59, dout_60, dout_61, dout_62, dout_63, dout_64, dout_65, dout_66, dout_67, dout_68, dout_69, dout_70, dout_71, dout_72, dout_73, dout_74, dout_75, dout_76, dout_77, dout_78, dout_79, dout_80, dout_81, dout_82, dout_83, dout_84, dout_85, dout_87, dout_88, dout_89, dout_90, dout_91, dout_92, dout_93, dout_94, dout_95, dout_96, dout_97, dout_98, dout_99, dout_100, dout_101, dout_102, dout_103, dout_104, dout_105, dout_106, dout_107, dout_108, dout_109, dout_110, dout_111, dout_112, dout_113, dout_114, dout_115, dout_116, dout_117, dout_118, dout_119, dout_120, dout_121, dout_122, dout_123, dout_124, dout_125, dout_126, dout_127, dout_128, dout_129, dout_130, dout_131, dout_132, dout_133, dout_134, dout_135, dout_136, dout_137, dout_138, dout_139, dout_140, dout_141, dout_142, dout_143, dout_144, dout_145, dout_146, dout_147, dout_148, dout_149, dout_150, dout_151, dout_152, dout_153, dout_154, dout_155, dout_156, dout_157, dout_158, dout_159, dout_160, dout_161, dout_162, dout_163, dout_164, dout_165, dout_166, dout_167, dout_168, dout_169, dout_170, dout_171, dout_172, dout_173, dout_174, dout_175, dout_176, dout_177, dout_178, dout_179, dout_180, dout_181, dout_182, dout_183, dout_184, dout_185, dout_186, dout_187, dout_188, dout_189, dout_190, dout_191, dout_192, dout_193, dout_194, dout_195, dout_196, dout_197, dout_198, dout_199, dout_200, dout_201, dout_202, dout_203, dout_204, dout_205, dout_206, dout_207, dout_208, dout_209, dout_210, dout_211, dout_212, dout_213, dout_214, dout_215, dout_216, dout_217, dout_218, dout_219, dout_220, dout_221, dout_222, dout_223, dout_224, dout_225, dout_226, dout_227, dout_228, dout_229, dout_230, dout_231, dout_232, dout_233, dout_234, dout_235, dout_236, dout_237, dout_238, dout_239, dout_240, dout_241, dout_242, dout_243, dout_244, dout_245, dout_246, dout_247, dout_248, dout_249, dout_250, dout_251, dout_252, dout_253, dout_254, dout_255, dout_256, dout_257, dout_258, dout_259, dout_260, dout_261, dout_262, dout_263, dout_264, dout_265, dout_266, dout_267, dout_268, dout_269, dout_270, dout_271, dout_272, dout_273, dout_274, dout_275, dout_276, dout_277, dout_278, dout_279, dout_280, dout_281, dout_282, dout_283, dout_284, dout_285, dout_286, dout_287, dout_288, dout_289, dout_290, dout_291, dout_292, dout_293, dout_294, dout_295, dout_296, dout_297, dout_298, dout_299, dout_300, dout_301, dout_302, dout_303, dout_304, dout_305, dout_306, dout_307, dout_308, dout_309, dout_310, dout_311, dout_312, dout_313, dout_314, dout_315, dout_316, dout_317, dout_318, dout_319, dout_320, dout_321, dout_322, dout_323, dout_324, dout_325, dout_326, dout_327, dout_328, dout_329, dout_330, dout_331, dout_332, dout_333, dout_334, dout_335; int avg=0; dout_18=((B >> 2)&1)&((A >> 0)&1); dout_19=((B >> 3)&1)&((A >> 0)&1); dout_20=((B >> 4)&1)&((A >> 0)&1); dout_21=((B >> 5)&1)&((A >> 0)&1); dout_22=((B >> 6)&1)&((A >> 0)&1); dout_23=((B >> 7)&1)&((A >> 0)&1); dout_25=((B >> 1)&1)&((A >> 1)&1); dout_26=((B >> 2)&1)&((A >> 1)&1); dout_27=((B >> 3)&1)&((A >> 1)&1); dout_28=((B >> 4)&1)&((A >> 1)&1); dout_29=((B >> 5)&1)&((A >> 1)&1); dout_30=((B >> 6)&1)&((A >> 1)&1); dout_31=((B >> 7)&1)&((A >> 1)&1); dout_33=((B >> 6)&1)&dout_31; dout_34=dout_18|dout_25; dout_35=dout_18&dout_25; dout_36=dout_19^dout_26; dout_37=dout_19&dout_26; dout_38=dout_20^dout_27; dout_39=dout_20&dout_27; dout_40=dout_21^dout_28; dout_41=dout_21&dout_28; dout_42=dout_22^dout_29; dout_43=dout_22&dout_29; dout_44=dout_23^dout_30; dout_45=((A >> 0)&1)&dout_33; dout_46=((B >> 0)&1)&((A >> 2)&1); dout_47=((B >> 1)&1)&((A >> 2)&1); dout_48=((B >> 2)&1)&((A >> 2)&1); dout_49=((B >> 3)&1)&((A >> 2)&1); dout_50=((B >> 4)&1)&((A >> 2)&1); dout_51=((B >> 5)&1)&((A >> 2)&1); dout_52=((B >> 6)&1)&((A >> 2)&1); dout_53=((B >> 7)&1)&((A >> 2)&1); dout_54=dout_34^dout_46; dout_55=dout_34&dout_46; dout_59=dout_36^dout_47; dout_60=dout_36&dout_47; dout_61=dout_59&dout_35; dout_62=dout_59^dout_35; dout_63=dout_60|dout_61; dout_64=dout_38^dout_48; dout_65=dout_38&dout_48; dout_66=dout_64&dout_37; dout_67=dout_64^dout_37; dout_68=dout_65|dout_66; dout_69=dout_40^dout_49; dout_70=dout_40&dout_49; dout_71=dout_69&dout_39; dout_72=dout_69^dout_39; dout_73=dout_70|dout_71; dout_74=dout_42^dout_50; dout_75=dout_42&dout_50; dout_76=dout_74&dout_41; dout_77=dout_74^dout_41; dout_78=dout_75|dout_76; dout_79=dout_44^dout_51; dout_80=dout_44&dout_51; dout_81=dout_79&dout_43; dout_82=dout_79^dout_43; dout_83=dout_80|dout_81; dout_84=dout_31^dout_52; dout_85=dout_31&dout_52; dout_87=dout_84^dout_45; dout_88=dout_85|dout_45; dout_89=((B >> 0)&1)&((A >> 3)&1); dout_90=((B >> 1)&1)&((A >> 3)&1); dout_91=((B >> 2)&1)&((A >> 3)&1); dout_92=((B >> 3)&1)&((A >> 3)&1); dout_93=((B >> 4)&1)&((A >> 3)&1); dout_94=((B >> 5)&1)&((A >> 3)&1); dout_95=((B >> 6)&1)&((A >> 3)&1); dout_96=((B >> 7)&1)&((A >> 3)&1); dout_97=dout_62^dout_89; dout_98=dout_62&dout_89; dout_99=dout_97&dout_55; dout_100=dout_97^dout_55; dout_101=dout_98|dout_99; dout_102=dout_67^dout_90; dout_103=dout_67&dout_90; dout_104=dout_102&dout_63; dout_105=dout_102^dout_63; dout_106=dout_103|dout_104; dout_107=dout_72^dout_91; dout_108=dout_72&dout_91; dout_109=dout_107&dout_68; dout_110=dout_107^dout_68; dout_111=dout_108|dout_109; dout_112=dout_77^dout_92; dout_113=dout_77&dout_92; dout_114=dout_112&dout_73; dout_115=dout_112^dout_73; dout_116=dout_113|dout_114; dout_117=dout_82^dout_93; dout_118=dout_82&dout_93; dout_119=dout_117&dout_78; dout_120=dout_117^dout_78; dout_121=dout_118|dout_119; dout_122=dout_87^dout_94; dout_123=dout_87&dout_94; dout_124=dout_122&dout_83; dout_125=dout_122^dout_83; dout_126=dout_123|dout_124; dout_127=dout_53^dout_95; dout_128=dout_53&dout_95; dout_129=dout_127&dout_88; dout_130=dout_127^dout_88; dout_131=dout_128|dout_129; dout_132=((B >> 0)&1)&((A >> 4)&1); dout_133=((B >> 1)&1)&((A >> 4)&1); dout_134=((B >> 2)&1)&((A >> 4)&1); dout_135=((B >> 3)&1)&((A >> 4)&1); dout_136=((B >> 4)&1)&((A >> 4)&1); dout_137=((B >> 5)&1)&((A >> 4)&1); dout_138=((B >> 6)&1)&((A >> 4)&1); dout_139=((B >> 7)&1)&((A >> 4)&1); dout_140=dout_105^dout_132; dout_141=dout_105&dout_132; dout_142=dout_140&dout_101; dout_143=dout_140^dout_101; dout_144=dout_141|dout_142; dout_145=dout_110^dout_133; dout_146=dout_110&dout_133; dout_147=dout_145&dout_106; dout_148=dout_145^dout_106; dout_149=dout_146|dout_147; dout_150=dout_115^dout_134; dout_151=dout_115&dout_134; dout_152=dout_150&dout_111; dout_153=dout_150^dout_111; dout_154=dout_151|dout_152; dout_155=dout_120^dout_135; dout_156=dout_120&dout_135; dout_157=dout_155&dout_116; dout_158=dout_155^dout_116; dout_159=dout_156|dout_157; dout_160=dout_125^dout_136; dout_161=dout_125&dout_136; dout_162=dout_160&dout_121; dout_163=dout_160^dout_121; dout_164=dout_161|dout_162; dout_165=dout_130^dout_137; dout_166=dout_130&dout_137; dout_167=dout_165&dout_126; dout_168=dout_165^dout_126; dout_169=dout_166|dout_167; dout_170=dout_96^dout_138; dout_171=dout_96&dout_138; dout_172=dout_170&dout_131; dout_173=dout_170^dout_131; dout_174=dout_171|dout_172; dout_175=((B >> 0)&1)&((A >> 5)&1); dout_176=((B >> 1)&1)&((A >> 5)&1); dout_177=((B >> 2)&1)&((A >> 5)&1); dout_178=((B >> 3)&1)&((A >> 5)&1); dout_179=((B >> 4)&1)&((A >> 5)&1); dout_180=((B >> 5)&1)&((A >> 5)&1); dout_181=((B >> 6)&1)&((A >> 5)&1); dout_182=((B >> 7)&1)&((A >> 5)&1); dout_183=dout_148^dout_175; dout_184=dout_148&dout_175; dout_185=dout_183&dout_144; dout_186=dout_183^dout_144; dout_187=dout_184|dout_185; dout_188=dout_153^dout_176; dout_189=dout_153&dout_176; dout_190=dout_188&dout_149; dout_191=dout_188^dout_149; dout_192=dout_189|dout_190; dout_193=dout_158^dout_177; dout_194=dout_158&dout_177; dout_195=dout_193&dout_154; dout_196=dout_193^dout_154; dout_197=dout_194|dout_195; dout_198=dout_163^dout_178; dout_199=dout_163&dout_178; dout_200=dout_198&dout_159; dout_201=dout_198^dout_159; dout_202=dout_199|dout_200; dout_203=dout_168^dout_179; dout_204=dout_168&dout_179; dout_205=dout_203&dout_164; dout_206=dout_203^dout_164; dout_207=dout_204|dout_205; dout_208=dout_173^dout_180; dout_209=dout_173&dout_180; dout_210=dout_208&dout_169; dout_211=dout_208^dout_169; dout_212=dout_209|dout_210; dout_213=dout_139^dout_181; dout_214=dout_139&dout_181; dout_215=dout_213&dout_174; dout_216=dout_213^dout_174; dout_217=dout_214|dout_215; dout_218=((B >> 0)&1)&((A >> 6)&1); dout_219=((B >> 1)&1)&((A >> 6)&1); dout_220=((B >> 2)&1)&((A >> 6)&1); dout_221=((B >> 3)&1)&((A >> 6)&1); dout_222=((B >> 4)&1)&((A >> 6)&1); dout_223=((B >> 5)&1)&((A >> 6)&1); dout_224=((B >> 6)&1)&((A >> 6)&1); dout_225=((B >> 7)&1)&((A >> 6)&1); dout_226=dout_191^dout_218; dout_227=dout_191&dout_218; dout_228=dout_226&dout_187; dout_229=dout_226^dout_187; dout_230=dout_227|dout_228; dout_231=dout_196^dout_219; dout_232=dout_196&dout_219; dout_233=dout_231&dout_192; dout_234=dout_231^dout_192; dout_235=dout_232|dout_233; dout_236=dout_201^dout_220; dout_237=dout_201&dout_220; dout_238=dout_236&dout_197; dout_239=dout_236^dout_197; dout_240=dout_237|dout_238; dout_241=dout_206^dout_221; dout_242=dout_206&dout_221; dout_243=dout_241&dout_202; dout_244=dout_241^dout_202; dout_245=dout_242|dout_243; dout_246=dout_211^dout_222; dout_247=dout_211&dout_222; dout_248=dout_246&dout_207; dout_249=dout_246^dout_207; dout_250=dout_247|dout_248; dout_251=dout_216^dout_223; dout_252=dout_216&dout_223; dout_253=dout_251&dout_212; dout_254=dout_251^dout_212; dout_255=dout_252|dout_253; dout_256=dout_182^dout_224; dout_257=dout_182&dout_224; dout_258=dout_256&dout_217; dout_259=dout_256^dout_217; dout_260=dout_257|dout_258; dout_261=((B >> 0)&1)&((A >> 7)&1); dout_262=((B >> 1)&1)&((A >> 7)&1); dout_263=((B >> 2)&1)&((A >> 7)&1); dout_264=((B >> 3)&1)&((A >> 7)&1); dout_265=((B >> 4)&1)&((A >> 7)&1); dout_266=((B >> 5)&1)&((A >> 7)&1); dout_267=((B >> 6)&1)&((A >> 7)&1); dout_268=((B >> 7)&1)&((A >> 7)&1); dout_269=dout_234^dout_261; dout_270=dout_234&dout_261; dout_271=dout_269&dout_230; dout_272=dout_269^dout_230; dout_273=dout_270|dout_271; dout_274=dout_239^dout_262; dout_275=dout_239&dout_262; dout_276=dout_274&dout_235; dout_277=dout_274^dout_235; dout_278=dout_275|dout_276; dout_279=dout_244^dout_263; dout_280=dout_244&dout_263; dout_281=dout_279&dout_240; dout_282=dout_279^dout_240; dout_283=dout_280|dout_281; dout_284=dout_249^dout_264; dout_285=dout_249&dout_264; dout_286=dout_284&dout_245; dout_287=dout_284^dout_245; dout_288=dout_285|dout_286; dout_289=dout_254^dout_265; dout_290=dout_254&dout_265; dout_291=dout_289&dout_250; dout_292=dout_289^dout_250; dout_293=dout_290|dout_291; dout_294=dout_259^dout_266; dout_295=dout_259&dout_266; dout_296=dout_294&dout_255; dout_297=dout_294^dout_255; dout_298=dout_295|dout_296; dout_299=dout_225^dout_267; dout_300=dout_225&dout_267; dout_301=dout_299&dout_260; dout_302=dout_299^dout_260; dout_303=dout_300|dout_301; dout_304=dout_277^dout_273; dout_305=dout_277&dout_273; dout_306=dout_282^dout_278; dout_307=dout_282&dout_278; dout_308=dout_306&dout_305; dout_309=dout_306^dout_305; dout_310=dout_307|dout_308; dout_311=dout_287^dout_283; dout_312=dout_287&dout_283; dout_313=dout_311&dout_310; dout_314=dout_311^dout_310; dout_315=dout_312|dout_313; dout_316=dout_292^dout_288; dout_317=dout_292&dout_288; dout_318=dout_316&dout_315; dout_319=dout_316^dout_315; dout_320=dout_317|dout_318; dout_321=dout_297^dout_293; dout_322=dout_297&dout_293; dout_323=dout_321&dout_320; dout_324=dout_321^dout_320; dout_325=dout_322|dout_323; dout_326=dout_302^dout_298; dout_327=dout_302&dout_298; dout_328=dout_326&dout_325; dout_329=dout_326^dout_325; dout_330=dout_327|dout_328; dout_331=dout_268^dout_303; dout_332=((A >> 7)&1)&dout_303; dout_333=dout_331&dout_330; dout_334=dout_331^dout_330; dout_335=dout_332|dout_333; O = 0; O |= (dout_130&1) << 0; O |= (((B >> 0)&1)&1) << 1; O |= (dout_54&1) << 2; O |= (dout_100&1) << 3; O |= (dout_143&1) << 4; O |= (dout_186&1) << 5; O |= (dout_229&1) << 6; O |= (dout_272&1) << 7; O |= (dout_304&1) << 8; O |= (dout_309&1) << 9; O |= (dout_314&1) << 10; O |= (dout_319&1) << 11; O |= (dout_324&1) << 12; O |= (dout_329&1) << 13; O |= (dout_334&1) << 14; O |= (dout_335&1) << 15; return O; }
the_stack_data/142334.c
/* Simple functions to support the run-time library when using the AdaCore GNAT GCC distribution, which doesn't have the * standard C system startup files in the run time library. */ /* Gets called if the main function returns. Some of the GNAT run-time components handle this by causing a machine reset. * This version just spins in a loop to allow the debugger to inspect state. */ void _exit (int status) { for (;;) { } }
the_stack_data/50138165.c
#include <stdio.h> int main(void) { printf("signed int decimal = %d\n", signed_int_decimal()); printf("signed int octal = %d\n", signed_int_octal()); printf("signed int hexadecimal = %d\n", signed_int_hexadecimal()); printf("unsigned int decimal = %u\n", unsigned_int_decimal()); printf("unsigned int octal = %o\n", unsigned_int_octal()); printf("unsigned int hexadecimal = %x\n", unsigned_int_hexadecimal()); printf("signed long decimal = %ld\n", signed_long_decimal()); printf("signed long octal = %ld\n", signed_long_octal()); printf("signed long hexadecimal = %ld\n", signed_long_hexadecimal()); printf("unsigned long decimal = %lu\n", unsigned_long_decimal()); printf("unsigned long octal = %lo\n", unsigned_long_octal()); printf("unsigned long hexadecimal = %lx\n", unsigned_long_hexadecimal()); printf("signed long long decimal = %lld\n", signed_long_long_decimal()); printf("signed long long octal = %lld\n", signed_long_long_octal()); printf("signed long long hexadecimal = %lld\n", signed_long_long_hexadecimal()); printf("unsigned long long decimal = %llu\n", unsigned_long_long_decimal()); printf("unsigned long long octal = %llo\n", unsigned_long_long_octal()); printf("unsigned long long hexadecimal = %llx\n", unsigned_long_long_hexadecimal()); return 0; }
the_stack_data/182953973.c
#include <stdio.h> #include <stdlib.h> struct Node { struct Node *prev; int data; struct Node *next; } *first = NULL; /* --------------- PROTOTYPES --------------- */ void create(int array[], int length); void display(struct Node *currentNode); int getLength(struct Node *currentNode); void insert(struct Node *currentNode, int index, int value); int del(struct Node *currentNode, int index); void reverse(struct Node *currentNode); /* --------------- FUNCTIONS --------------- */ void create(int array[], int length) { struct Node *temp, *last; int i; // First node initialization. first = (struct Node *)malloc(sizeof(struct Node)); first->data = array[0]; first->prev = NULL; first->next = NULL; last = first; for (i = 1; i < length; i++) { temp = (struct Node *)malloc(sizeof(struct Node)); temp->data = array[i]; temp->next = last->next; temp->prev = last; last->next = temp; last = temp; } } void display(struct Node *currentNode) { while (currentNode != NULL) { printf("%d ", currentNode->data); currentNode = currentNode->next; } printf("\n"); } int getLength(struct Node *currentNode) { int len = 0; while (currentNode != NULL) { len++; currentNode = currentNode->next; } return len; } void insert(struct Node *currentNode, int index, int value) { struct Node *temp; int i; if (index < 0 || index > getLength(currentNode)) { return; } if (index == 0) { temp = (struct Node *)malloc(sizeof(struct Node)); temp->data = value; temp->next = first; temp->prev = NULL; first->prev = temp; first = temp; } else { for (i = 0; i < index - 1; i++) { currentNode = currentNode->next; } temp = (struct Node *)malloc(sizeof(struct Node)); temp->data = value; temp->prev = currentNode; temp->next = currentNode->next; if (currentNode->next) { currentNode->next->prev = temp; } currentNode->next = temp; } } int del(struct Node *currentNode, int index) { int i, value = -1; if (index < 1 || index > getLength(currentNode)) { return value; } if (index == 1) { first = first->next; if (first) { first->prev = NULL; } value = currentNode->data; free(currentNode); } else { for (i = 0; i < index - 1; i++) { currentNode = currentNode->next; } currentNode->prev->next = currentNode->next; if (currentNode->next) { currentNode->next->prev = currentNode->prev; } value = currentNode->data; free(currentNode); } return value; } void reverse(struct Node *currentNode) { struct Node *temp; while (currentNode != NULL) { temp = currentNode->next; currentNode->next = currentNode->prev; currentNode->prev = temp; currentNode = currentNode->prev; if (currentNode != NULL && currentNode->next == NULL) { first = currentNode; } } } /* --------------- MAIN --------------- */ int main() { int numbers[] = { 10, 20, 30, 40, 50 }; create(numbers, sizeof(numbers) / sizeof(numbers[0])); reverse(first); printf("Linked list is:\n"); display(first); return 0; }
the_stack_data/161079609.c
// SKIP PARAM: --set solver td3 --enable ana.int.interval --enable ana.base.partition-arrays.enabled --set ana.base.partition-arrays.keep-expr "last" --set ana.activated "['base','threadid','threadflag','escape','expRelation','apron','mallocWrapper']" --set ana.base.privatization none --enable annotation.int.enabled --set ana.int.refinement fixpoint --set sem.int.signed_overflow assume_none void main(void) __attribute__((goblint_precision("no-interval"))); void example1(void) __attribute__((goblint_precision("no-def_exc"))); void example2(void) __attribute__((goblint_precision("no-def_exc"))); void example3(void) __attribute__((goblint_precision("no-def_exc"))); void example4(void) __attribute__((goblint_precision("no-def_exc"))); void example4a(void) __attribute__((goblint_precision("no-def_exc"))); void example4b(void) __attribute__((goblint_precision("no-def_exc"))); void example4c(void) __attribute__((goblint_precision("no-def_exc"))); void example5(void) __attribute__((goblint_precision("no-def_exc"))); void example6(void) __attribute__((goblint_precision("no-def_exc"))); void example8(void) __attribute__((goblint_precision("no-def_exc"))); void mineEx1(void) __attribute__((goblint_precision("no-def_exc"))); void main(void) { example1(); example2(); example3(); example4(); example4a(); example4b(); example4c(); example5(); example6(); example7(); example8(); mineEx1(); } void example1(void) { int a[20]; int i = 0; int j = 0; int top; int z; // Necessary so we can not answer the queries below from the base domain // and actually test the behavior of the octagons int between1and8; if(between1and8 < 1) { between1and8 = 1; } if(between1and8 > 8) { between1and8 = 8; } while(i < 20) { a[i] = 0; i++; } while(j < between1and8) { a[j] = 1; j++; } a[j] = 2; // a -> (j,([1,1],[2,2],[0,0])) if(top) { z = j; } else { z = j-1; } // Values that may be read are 1 or 2 assert(a[z] == 1); //UNKNOWN assert(a[z] == 2); //UNKNOWN // Relies on option sem.int.signed_overflow assume_none assert(a[z] != 0); } void example2(void) { int a[20]; int i = 0; int j = 0; int top; int z; // Necessary so we can not answer the queries below from the base domain // and actually test the behavior of the octagons int between1and8; if(between1and8 < 1) { between1and8 = 1; } if(between1and8 > 8) { between1and8 = 8; } while(i < 20) { a[i] = 0; i++; } while(j < between1and8) { a[j] = 2; j++; } a[j] = 1; // a -> (j,([2,2],[1,1],[0,0])) if(top) { z = j; } else { z = j+1; } // Values that may be read are 1 or 0 assert(a[z] == 1); //UNKNOWN assert(a[z] == 0); //UNKNOWN // Relies on option sem.int.signed_overflow assume_none assert(a[z] != 2); } // Simple example (employing MustBeEqual) void example3(void) { int a[42]; int i = 0; int x; while(i < 42) { a[i] = 0; int v = i; x = a[v]; assert(x == 0); i++; } } // Simple example (employing MayBeEqual / MayBeSmaller) void example4(void) { int a[42]; int i = 0; while(i<=9) { a[i] = 9; int j = i+5; a[j] = 42; // Here we know a[i] is 9 when we have MayBeEqual assert(a[i] == 9); // UNKNOWN // but only about the part to the left of i if we also have MayBeSmaller if(i>0) { int k = a[i-1]; assert(k == 9); // UNKNOWN int l = a[0]; assert(l == 9); // UNKNOWN } i++; } } // Just like the example before except that it tests correct behavior when variable order is reversed void example4a(void) { int a[42]; int j; int i = 0; while(i<=9) { a[i] = 9; j = i+5; a[j] = 42; // Here we know a[i] is 9 when we have MayBeEqual assert(a[i] == 9); //UNKNOWN // but only about the part to the left of i if we also have MayBeSmaller if(i>0) { assert(a[i-1] == 9); //UNKNOWN } i++; } } // Just like the example before except that it tests correct behavior when operands for + are reversed void example4b(void) { int a[42]; int j; int i = 0; while(i<=9) { a[i] = 9; j = 5+i; a[j] = 42; // Here we know a[i] is 9 when we have MayBeEqual assert(a[i] == 9); //UNKNOWN // but only about the part to the left of i if we also have MayBeSmaller if(i>0) { assert(a[i-1] == 9); //UNKNOWN } i++; } } // Like example before but iterating backwards void example4c(void) { int a[42]; int j; int i = 41; while(i > 8) { a[i] = 7; a[i-2] = 31; if(i < 41) { assert(a[i+1] == 7); //UNKNOWN } i--; } } void example5(void) { int a[40]; int i = 0; // This is a dirty cheat to get the array to be partitioned before entering the loop // This is needed because the may be less of the octagons is not sophisticated enough yet. // Once that is fixed this will also work without this line a[i] = 0; while(i < 42) { int j = i; a[j] = 0; i++; assert(a[i] == 0); //UNKNOWN assert(a[i-1] == 0); assert(a[j] == 0); if (i>1) { assert(a[i-2] == 0); assert(a[j-1] == 0); } } } void example6(void) { int a[42]; int i = 0; int top; while(i<30) { a[i] = 0; i++; assert(a[top] == 0); //UNKNOWN int j=0; while(j<i) { assert(a[j] == 0); j++; } } } void example7(void) { int top; int a[42]; int i = 0; int j; while(i<30) { a[i] = 0; i++; if(i > 10) { if(top) { j = i-5; } else { j = i-7; } assert(a[j] == 0); } } } void example8(void) { int a[42]; int i = 0; int j = i; int N; if(N < 5) { N = 5; } if(N > 40) { N = 40; } while(i < N) { a[i] = 0; i++; j = i; a[j-1] = 0; a[j] = 0; j++; // Octagon knows -1 <= i-j <= -1 i = j; // Without octagons, we lose partitioning here because we don't know how far the move has been assert(a[i-1] == 0); assert(a[i-2] == 0); } j = 0; while(j < N) { assert(a[j] == 0); //UNKNOWN j++; } } // Example from https://www-apr.lip6.fr/~mine/publi/article-mine-HOSC06.pdf void mineEx1(void) { int X = 0; int N = rand(); if(N < 0) { N = 0; } while(X < N) { X++; } assert(X-N == 0); // assert(X == N); // Currently not able to assert this because octagon doesn't handle it if(X == N) { N = 8; } else { // is dead code but if that is detected or not depends on what we do in branch // currenlty we can't detect this N = 42; } }
the_stack_data/11074700.c
/* Copyright 2017 Cedric Mesnil <[email protected]>, Ledger SAS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const char * const C_TEMPLATE_TYPE = "Key type"; const char * const C_TEMPLATE_KEY = "Key"; const char * const C_INVALID_SELECTION = "Invalid selection"; const char * const C_OK = "OK"; const char * const C_NOK = "NOK"; const char * const C_WRONG_PIN = "PIN Incorrect"; const char * const C_RIGHT_PIN = "PIN Correct"; const char * const C_PIN_CHANGED = "PIN changed"; const char * const C_PIN_DIFFERS = "2 PINs differs"; const char * const C_PIN_USER = "User PIN"; const char * const C_PIN_ADMIN = "Admin PIN"; const char * const C_VERIFIED = "Verified"; const char * const C_NOT_VERIFIED = "Not Verified"; const char * const C_ALLOWED = "Allowed"; const char * const C_NOT_ALLOWED = "Not Allowed "; const char * const C_DEFAULT_MODE = "Default mode"; const char * const C_UIF_LOCKED = "UIF locked";
the_stack_data/93641.c
#include <stdio.h> #define NUM 1000 void prime(int table[]) { int i, j; for(i = 0; i < NUM; i++) table[i] = 1; table[0] = 0; for(i = 2; i * i < NUM; i++) { if(table[i] == 1) { for(j = i * 2; j < NUM; j += i){ table[j] = 0; } } } return; } void show(int table[]) { int count = 1; for(int i = 2; i < NUM; i++) { if(table[i] == 1) { printf("%4d", i); count++; } if(count % 10 == 0) { puts(""); count++; } } puts(""); return; } int main() { int table[NUM]; prime(table); show(table); return 0; }
the_stack_data/45449855.c
#include <stdlib.h> #include <ctype.h> int main() { char a[5] = {'1', 'a', 'A', '\n', 'Q'}; char b[5] = {'1', 'a', 'a', '\n', 'q'}; for (int i = 0; i < 5; i++) { if (b[i] != tolower(a[i])) return EXIT_FAILURE; } return EXIT_SUCCESS; }
the_stack_data/73307.c
#ifndef TH_GENERIC_FILE #define TH_GENERIC_FILE "generic/THTensorLapack.c" #else /* Check if self is transpose of a contiguous matrix */ static int THTensor_(isTransposedContiguous)(THTensor *self) { return self->stride[0] == 1 && self->stride[1] == self->size[0]; } /* If a matrix is a regular contiguous matrix, make sure it is transposed because this is what we return from Lapack calls. */ static void THTensor_(checkTransposed)(THTensor *self) { if(THTensor_(isContiguous)(self)) THTensor_(transpose)(self, NULL, 0, 1); return; } /* newContiguous followed by transpose Similar to (newContiguous), but checks if the transpose of the matrix is contiguous and also limited to 2D matrices. */ static THTensor *THTensor_(newTransposedContiguous)(THTensor *self) { THTensor *tensor; if(THTensor_(isTransposedContiguous)(self)) { THTensor_(retain)(self); tensor = self; } else { tensor = THTensor_(newContiguous)(self); THTensor_(transpose)(tensor, NULL, 0, 1); } return tensor; } /* Given the result tensor and src tensor, decide if the lapack call should use the provided result tensor or should allocate a new space to put the result in. The returned tensor have to be freed by the calling function. nrows is required, because some lapack calls, require output space smaller than input space, like underdetermined gels. */ static THTensor *THTensor_(checkLapackClone)(THTensor *result, THTensor *src, int nrows) { /* check if user wants to reuse src and if it is correct shape/size */ if (src == result && THTensor_(isTransposedContiguous)(src) && src->size[1] == nrows) THTensor_(retain)(result); else if(src == result || result == NULL) /* in this case, user wants reuse of src, but its structure is not OK */ result = THTensor_(new)(); else THTensor_(retain)(result); return result; } /* Same as cloneColumnMajor, but accepts nrows argument, because some lapack calls require the resulting tensor to be larger than src. */ static THTensor *THTensor_(cloneColumnMajorNrows)(THTensor *self, THTensor *src, int nrows) { THTensor *result; THTensor *view; if (src == NULL) src = self; result = THTensor_(checkLapackClone)(self, src, nrows); if (src == result) return result; THTensor_(resize2d)(result, src->size[1], nrows); THTensor_(checkTransposed)(result); if (src->size[0] == nrows) THTensor_(copy)(result, src); else { view = THTensor_(newNarrow)(result, 0, 0, src->size[0]); THTensor_(copy)(view, src); THTensor_(free)(view); } return result; } /* Create a clone of src in self column major order for use with Lapack. If src == self, a new tensor is allocated, in any case, the return tensor should be freed by calling function. */ static THTensor *THTensor_(cloneColumnMajor)(THTensor *self, THTensor *src) { return THTensor_(cloneColumnMajorNrows)(self, src, src->size[0]); } void THTensor_(gesv)(THTensor *rb_, THTensor *ra_, THTensor *b, THTensor *a) { int free_b = 0; if (a == NULL) a = ra_; if (b == NULL) b = rb_; THArgCheck(a->nDimension == 2, 2, "A should have 2 dimensions, but has %d", a->nDimension); THArgCheck(b->nDimension == 1 || b->nDimension == 2, 1, "B should have 1 or 2 " "dimensions, but has %d", b->nDimension); THArgCheck(a->size[0] == a->size[1], 2, "A should be square, but is %ldx%ld", a->size[0], a->size[1]); THArgCheck(a->size[0] == b->size[0], 2, "A,B size incompatible - A has %ld " "rows, B has %ld", a->size[0], b->size[0]); if (b->nDimension == 1) { b = THTensor_(newWithStorage2d)(b->storage, b->storageOffset, b->size[0], b->stride[0], 1, 0); free_b = 1; } int n, nrhs, lda, ldb, info; THIntTensor *ipiv; THTensor *ra__; // working version of A matrix to be passed into lapack GELS THTensor *rb__; // working version of B matrix to be passed into lapack GELS ra__ = THTensor_(cloneColumnMajor)(ra_, a); rb__ = THTensor_(cloneColumnMajor)(rb_, b); n = (int)ra__->size[0]; nrhs = (int)rb__->size[1]; lda = n; ldb = n; ipiv = THIntTensor_newWithSize1d((long)n); THLapack_(gesv)(n, nrhs, THTensor_(data)(ra__), lda, THIntTensor_data(ipiv), THTensor_(data)(rb__), ldb, &info); THLapackCheckWithCleanup("Lapack Error in %s : U(%d,%d) is zero, singular U.", THCleanup( THTensor_(free)(ra__); THTensor_(free)(rb__); THIntTensor_free(ipiv); if (free_b) THTensor_(free)(b);), "gesv", info, info); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(freeCopyTo)(rb__, rb_); THIntTensor_free(ipiv); if (free_b) THTensor_(free)(b); } void THTensor_(trtrs)(THTensor *rb_, THTensor *ra_, THTensor *b, THTensor *a, const char *uplo, const char *trans, const char *diag) { int free_b = 0; if (a == NULL) a = ra_; if (b == NULL) b = rb_; THArgCheck(a->nDimension == 2, 2, "A should have 2 dimensions, but has %d", a->nDimension); THArgCheck(b->nDimension == 1 || b->nDimension == 2, 1, "B should have 1 or 2 " "dimensions, but has %d", b->nDimension); THArgCheck(a->size[0] == a->size[1], 2, "A should be square, but is %ldx%ld", a->size[0], a->size[1]); THArgCheck(a->size[0] == b->size[0], 2, "A,B size incompatible - A has %ld " "rows, B has %ld", a->size[0], b->size[0]); if (b->nDimension == 1) { b = THTensor_(newWithStorage2d)(b->storage, b->storageOffset, b->size[0], b->stride[0], 1, 0); free_b = 1; } int n, nrhs, lda, ldb, info; THTensor *ra__; // working version of A matrix to be passed into lapack TRTRS THTensor *rb__; // working version of B matrix to be passed into lapack TRTRS ra__ = THTensor_(cloneColumnMajor)(ra_, a); rb__ = THTensor_(cloneColumnMajor)(rb_, b); n = (int)ra__->size[0]; nrhs = (int)rb__->size[1]; lda = n; ldb = n; THLapack_(trtrs)(uplo[0], trans[0], diag[0], n, nrhs, THTensor_(data)(ra__), lda, THTensor_(data)(rb__), ldb, &info); THLapackCheckWithCleanup("Lapack Error in %s : A(%d,%d) is zero, singular A", THCleanup( THTensor_(free)(ra__); THTensor_(free)(rb__); if (free_b) THTensor_(free)(b);), "trtrs", info, info); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(freeCopyTo)(rb__, rb_); if (free_b) THTensor_(free)(b); } void THTensor_(gels)(THTensor *rb_, THTensor *ra_, THTensor *b, THTensor *a) { int free_b = 0; // Note that a = NULL is interpreted as a = ra_, and b = NULL as b = rb_. if (a == NULL) a = ra_; if (b == NULL) b = rb_; THArgCheck(a->nDimension == 2, 2, "A should have 2 dimensions, but has %d", a->nDimension); THArgCheck(b->nDimension == 1 || b->nDimension == 2, 1, "B should have 1 or 2 " "dimensions, but has %d", b->nDimension); THArgCheck(a->size[0] == b->size[0], 2, "A,B size incompatible - A has %ld " "rows, B has %ld", a->size[0], b->size[0]); if (b->nDimension == 1) { b = THTensor_(newWithStorage2d)(b->storage, b->storageOffset, b->size[0], b->stride[0], 1, 0); free_b = 1; } int m, n, nrhs, lda, ldb, info, lwork; THTensor *work = NULL; real wkopt = 0; THTensor *ra__ = NULL; // working version of A matrix to be passed into lapack GELS THTensor *rb__ = NULL; // working version of B matrix to be passed into lapack GELS ra__ = THTensor_(cloneColumnMajor)(ra_, a); m = ra__->size[0]; n = ra__->size[1]; lda = m; ldb = (m > n) ? m : n; rb__ = THTensor_(cloneColumnMajorNrows)(rb_, b, ldb); nrhs = rb__->size[1]; info = 0; /* get optimal workspace size */ THLapack_(gels)('N', m, n, nrhs, THTensor_(data)(ra__), lda, THTensor_(data)(rb__), ldb, &wkopt, -1, &info); lwork = (int)wkopt; work = THTensor_(newWithSize1d)(lwork); THLapack_(gels)('N', m, n, nrhs, THTensor_(data)(ra__), lda, THTensor_(data)(rb__), ldb, THTensor_(data)(work), lwork, &info); THLapackCheckWithCleanup("Lapack Error in %s : The %d-th diagonal element of the triangular factor of A is zero", THCleanup(THTensor_(free)(ra__); THTensor_(free)(rb__); THTensor_(free)(work); if (free_b) THTensor_(free)(b);), "gels", info,""); /* rb__ is currently ldb by nrhs; resize it to n by nrhs */ rb__->size[0] = n; if (rb__ != rb_) THTensor_(resize2d)(rb_, n, nrhs); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(freeCopyTo)(rb__, rb_); THTensor_(free)(work); if (free_b) THTensor_(free)(b); } void THTensor_(geev)(THTensor *re_, THTensor *rv_, THTensor *a_, const char *jobvr) { int n, lda, lwork, info, ldvr; THTensor *work, *wi, *wr, *a; real wkopt; real *rv_data; long i; THTensor *re__ = NULL; THTensor *rv__ = NULL; THArgCheck(a_->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a_->size[0] == a_->size[1], 1,"A should be square"); /* we want to definitely clone a_ for geev*/ a = THTensor_(cloneColumnMajor)(NULL, a_); n = a->size[0]; lda = n; wi = THTensor_(newWithSize1d)(n); wr = THTensor_(newWithSize1d)(n); rv_data = NULL; ldvr = 1; if (*jobvr == 'V') { THTensor_(resize2d)(rv_,n,n); /* guard against someone passing a correct size, but wrong stride */ rv__ = THTensor_(newTransposedContiguous)(rv_); rv_data = THTensor_(data)(rv__); ldvr = n; } THTensor_(resize2d)(re_,n,2); re__ = THTensor_(newContiguous)(re_); /* get optimal workspace size */ THLapack_(geev)('N', jobvr[0], n, THTensor_(data)(a), lda, THTensor_(data)(wr), THTensor_(data)(wi), NULL, 1, rv_data, ldvr, &wkopt, -1, &info); lwork = (int)wkopt; work = THTensor_(newWithSize1d)(lwork); THLapack_(geev)('N', jobvr[0], n, THTensor_(data)(a), lda, THTensor_(data)(wr), THTensor_(data)(wi), NULL, 1, rv_data, ldvr, THTensor_(data)(work), lwork, &info); THLapackCheckWithCleanup(" Lapack Error in %s : %d off-diagonal elements of an didn't converge to zero", THCleanup(THTensor_(free)(re__); THTensor_(free)(rv__); THTensor_(free)(a); THTensor_(free)(wi); THTensor_(free)(wr); THTensor_(free)(work);), "geev", info,""); { real *re_data = THTensor_(data)(re__); real *wi_data = THTensor_(data)(wi); real *wr_data = THTensor_(data)(wr); for (i=0; i<n; i++) { re_data[2*i] = wr_data[i]; re_data[2*i+1] = wi_data[i]; } } if (*jobvr == 'V') { THTensor_(checkTransposed)(rv_); THTensor_(freeCopyTo)(rv__, rv_); } THTensor_(freeCopyTo)(re__, re_); THTensor_(free)(a); THTensor_(free)(wi); THTensor_(free)(wr); THTensor_(free)(work); } void THTensor_(syev)(THTensor *re_, THTensor *rv_, THTensor *a, const char *jobz, const char *uplo) { if (a == NULL) a = rv_; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a->size[0] == a->size[1], 1,"A should be square"); int n, lda, lwork, info; THTensor *work; real wkopt; THTensor *rv__ = NULL; THTensor *re__ = NULL; rv__ = THTensor_(cloneColumnMajor)(rv_, a); n = rv__->size[0]; lda = n; THTensor_(resize1d)(re_,n); re__ = THTensor_(newContiguous)(re_); /* get optimal workspace size */ THLapack_(syev)(jobz[0], uplo[0], n, THTensor_(data)(rv__), lda, THTensor_(data)(re_), &wkopt, -1, &info); lwork = (int)wkopt; work = THTensor_(newWithSize1d)(lwork); THLapack_(syev)(jobz[0], uplo[0], n, THTensor_(data)(rv__), lda, THTensor_(data)(re_), THTensor_(data)(work), lwork, &info); THLapackCheckWithCleanup("Lapack Error %s : %d off-diagonal elements didn't converge to zero", THCleanup(THTensor_(free)(rv__); THTensor_(free)(re__); THTensor_(free)(work);), "syev", info,""); THTensor_(freeCopyTo)(rv__, rv_); THTensor_(freeCopyTo)(re__, re_); THTensor_(free)(work); } void THTensor_(gesvd)(THTensor *ru_, THTensor *rs_, THTensor *rv_, THTensor *a, const char* jobu) { THTensor *ra_ = THTensor_(new)(); THTensor_(gesvd2)(ru_, rs_, rv_, ra_, a, jobu); THTensor_(free)(ra_); } void THTensor_(gesvd2)(THTensor *ru_, THTensor *rs_, THTensor *rv_, THTensor *ra_, THTensor *a, const char* jobu) { if (a == NULL) a = ra_; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); int k,m, n, lda, ldu, ldvt, lwork, info; THTensor *work; THTensor *rvf_ = THTensor_(new)(); real wkopt; THTensor *ra__ = NULL; THTensor *ru__ = NULL; THTensor *rs__ = NULL; THTensor *rv__ = NULL; ra__ = THTensor_(cloneColumnMajor)(ra_, a); m = ra__->size[0]; n = ra__->size[1]; k = (m < n ? m : n); lda = m; ldu = m; ldvt = n; THTensor_(resize1d)(rs_,k); THTensor_(resize2d)(rvf_,ldvt,n); if (*jobu == 'A') THTensor_(resize2d)(ru_,m,ldu); else THTensor_(resize2d)(ru_,k,ldu); THTensor_(checkTransposed)(ru_); /* guard against someone passing a correct size, but wrong stride */ ru__ = THTensor_(newTransposedContiguous)(ru_); rs__ = THTensor_(newContiguous)(rs_); rv__ = THTensor_(newContiguous)(rvf_); THLapack_(gesvd)(jobu[0],jobu[0], m,n,THTensor_(data)(ra__),lda, THTensor_(data)(rs__), THTensor_(data)(ru__), ldu, THTensor_(data)(rv__), ldvt, &wkopt, -1, &info); lwork = (int)wkopt; work = THTensor_(newWithSize1d)(lwork); THLapack_(gesvd)(jobu[0],jobu[0], m,n,THTensor_(data)(ra__),lda, THTensor_(data)(rs__), THTensor_(data)(ru__), ldu, THTensor_(data)(rv__), ldvt, THTensor_(data)(work),lwork, &info); THLapackCheckWithCleanup(" Lapack Error %s : %d superdiagonals failed to converge.", THCleanup( THTensor_(free)(ru__); THTensor_(free)(rs__); THTensor_(free)(rv__); THTensor_(free)(ra__); THTensor_(free)(work);), "gesvd", info,""); if (*jobu == 'S') THTensor_(narrow)(rv__,NULL,1,0,k); THTensor_(freeCopyTo)(ru__, ru_); THTensor_(freeCopyTo)(rs__, rs_); THTensor_(freeCopyTo)(rv__, rvf_); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(free)(work); if (*jobu == 'S') { THTensor_(narrow)(rvf_,NULL,1,0,k); } THTensor_(resizeAs)(rv_, rvf_); THTensor_(copy)(rv_, rvf_); THTensor_(free)(rvf_); } void THTensor_(getri)(THTensor *ra_, THTensor *a) { if (a == NULL) a = ra_; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a->size[0] == a->size[1], 1, "A should be square"); int m, n, lda, info, lwork; real wkopt; THIntTensor *ipiv; THTensor *work; THTensor *ra__ = NULL; ra__ = THTensor_(cloneColumnMajor)(ra_, a); m = ra__->size[0]; n = ra__->size[1]; lda = m; ipiv = THIntTensor_newWithSize1d((long)m); /* Run LU */ THLapack_(getrf)(n, n, THTensor_(data)(ra__), lda, THIntTensor_data(ipiv), &info); THLapackCheckWithCleanup("Lapack Error %s : U(%d,%d) is 0, U is singular", THCleanup( THTensor_(free)(ra__); THIntTensor_free(ipiv);), "getrf", info, info); /* Run inverse */ THLapack_(getri)(n, THTensor_(data)(ra__), lda, THIntTensor_data(ipiv), &wkopt, -1, &info); lwork = (int)wkopt; work = THTensor_(newWithSize1d)(lwork); THLapack_(getri)(n, THTensor_(data)(ra__), lda, THIntTensor_data(ipiv), THTensor_(data)(work), lwork, &info); THLapackCheckWithCleanup("Lapack Error %s : U(%d,%d) is 0, U is singular", THCleanup( THTensor_(free)(ra__); THTensor_(free)(work); THIntTensor_free(ipiv);), "getri", info, info); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(free)(work); THIntTensor_free(ipiv); } void THTensor_(clearUpLoTriangle)(THTensor *a, const char *uplo) { THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a->size[0] == a->size[1], 1, "A should be square"); int n = a->size[0]; /* Build full matrix */ real *p = THTensor_(data)(a); long i, j; /* Upper Triangular Case */ if (uplo[0] == 'U') { /* Clear lower triangle (excluding diagonals) */ for (i=0; i<n; i++) { for (j=i+1; j<n; j++) { p[n*i + j] = 0; } } } /* Lower Triangular Case */ else if (uplo[0] == 'L') { /* Clear upper triangle (excluding diagonals) */ for (i=0; i<n; i++) { for (j=0; j<i; j++) { p[n*i + j] = 0; } } } } void THTensor_(copyUpLoTriangle)(THTensor *a, const char *uplo) { THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a->size[0] == a->size[1], 1, "A should be square"); int n = a->size[0]; /* Build full matrix */ real *p = THTensor_(data)(a); long i, j; /* Upper Triangular Case */ if (uplo[0] == 'U') { /* Clear lower triangle (excluding diagonals) */ for (i=0; i<n; i++) { for (j=i+1; j<n; j++) { p[n*i + j] = p[n*j+i]; } } } /* Lower Triangular Case */ else if (uplo[0] == 'L') { /* Clear upper triangle (excluding diagonals) */ for (i=0; i<n; i++) { for (j=0; j<i; j++) { p[n*i + j] = p[n*j+i]; } } } } void THTensor_(potrf)(THTensor *ra_, THTensor *a, const char *uplo) { if (a == NULL) a = ra_; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a->size[0] == a->size[1], 1, "A should be square"); int n, lda, info; THTensor *ra__ = NULL; ra__ = THTensor_(cloneColumnMajor)(ra_, a); n = ra__->size[0]; lda = n; /* Run Factorization */ THLapack_(potrf)(uplo[0], n, THTensor_(data)(ra__), lda, &info); THLapackCheckWithCleanup("Lapack Error in %s : the leading minor of order %d is not positive definite", THCleanup(THTensor_(free)(ra__);), "potrf", info, ""); THTensor_(clearUpLoTriangle)(ra__, uplo); THTensor_(freeCopyTo)(ra__, ra_); } void THTensor_(potrs)(THTensor *rb_, THTensor *b, THTensor *a, const char *uplo) { int free_b = 0; if (b == NULL) b = rb_; THArgCheck(a->nDimension == 2, 2, "A should have 2 dimensions, but has %d", a->nDimension); THArgCheck(b->nDimension == 1 || b->nDimension == 2, 1, "B should have 1 or 2 " "dimensions, but has %d", b->nDimension); THArgCheck(a->size[0] == a->size[1], 2, "A should be square, but is %ldx%ld", a->size[0], a->size[1]); THArgCheck(a->size[0] == b->size[0], 2, "A,B size incompatible - A has %ld " "rows, B has %ld", a->size[0], b->size[0]); if (b->nDimension == 1) { b = THTensor_(newWithStorage2d)(b->storage, b->storageOffset, b->size[0], b->stride[0], 1, 0); free_b = 1; } int n, nrhs, lda, ldb, info; THTensor *ra__; // working version of A matrix to be passed into lapack TRTRS THTensor *rb__; // working version of B matrix to be passed into lapack TRTRS ra__ = THTensor_(cloneColumnMajor)(NULL, a); rb__ = THTensor_(cloneColumnMajor)(rb_, b); n = (int)ra__->size[0]; nrhs = (int)rb__->size[1]; lda = n; ldb = n; THLapack_(potrs)(uplo[0], n, nrhs, THTensor_(data)(ra__), lda, THTensor_(data)(rb__), ldb, &info); THLapackCheckWithCleanup("Lapack Error in %s : A(%d,%d) is zero, singular A", THCleanup( THTensor_(free)(ra__); THTensor_(free)(rb__); if (free_b) THTensor_(free)(b);), "potrs", info, info); if (free_b) THTensor_(free)(b); THTensor_(free)(ra__); THTensor_(freeCopyTo)(rb__, rb_); } void THTensor_(potri)(THTensor *ra_, THTensor *a, const char *uplo) { if (a == NULL) a = ra_; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a->size[0] == a->size[1], 1, "A should be square"); int n, lda, info; THTensor *ra__ = NULL; ra__ = THTensor_(cloneColumnMajor)(ra_, a); n = ra__->size[0]; lda = n; /* Run inverse */ THLapack_(potri)(uplo[0], n, THTensor_(data)(ra__), lda, &info); THLapackCheckWithCleanup("Lapack Error %s : A(%d,%d) is 0, A cannot be factorized", THCleanup(THTensor_(free)(ra__);), "potri", info, info); THTensor_(copyUpLoTriangle)(ra__, uplo); THTensor_(freeCopyTo)(ra__, ra_); } /* Computes the Cholesky factorization with complete pivoting of a real symmetric positive semidefinite matrix. Args: * `ra_` - result Tensor in which to store the factor U or L from the Cholesky factorization. * `rpiv_` - result IntTensor containing sparse permutation matrix P, encoded as P[rpiv_[k], k] = 1. * `a` - input Tensor; the input matrix to factorize. * `uplo` - string; specifies whether the upper or lower triangular part of the symmetric matrix A is stored. "U"/"L" for upper/lower triangular. * `tol` - double; user defined tolerance, or < 0 for automatic choice. The algorithm terminates when the pivot <= tol. */ void THTensor_(pstrf)(THTensor *ra_, THIntTensor *rpiv_, THTensor *a, const char *uplo, real tol) { THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THArgCheck(a->size[0] == a->size[1], 1, "A should be square"); int n = a->size[0]; THTensor *ra__ = THTensor_(cloneColumnMajor)(ra_, a); THIntTensor_resize1d(rpiv_, n); // Allocate working tensor THTensor *work = THTensor_(newWithSize1d)(2 * n); // Run Cholesky factorization int lda = n; int rank, info; THLapack_(pstrf)(uplo[0], n, THTensor_(data)(ra__), lda, THIntTensor_data(rpiv_), &rank, tol, THTensor_(data)(work), &info); THLapackCheckWithCleanup("Lapack Error %s : matrix is rank deficient or not positive semidefinite", THCleanup( THTensor_(free)(ra__); THTensor_(free)(work);), "pstrf", info,""); THTensor_(clearUpLoTriangle)(ra__, uplo); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(free)(work); } /* Perform a QR decomposition of a matrix. In LAPACK, two parts of the QR decomposition are implemented as two separate functions: geqrf and orgqr. For flexibility and efficiency, these are wrapped directly, below - but to make the common usage convenient, we also provide this function, which calls them both and returns the results in a more intuitive form. Args: * `rq_` - result Tensor in which to store the Q part of the decomposition. * `rr_` - result Tensor in which to store the R part of the decomposition. * `a` - input Tensor; the matrix to decompose. */ void THTensor_(qr)(THTensor *rq_, THTensor *rr_, THTensor *a) { int m = a->size[0]; int n = a->size[1]; int k = (m < n ? m : n); THTensor *ra_ = THTensor_(new)(); THTensor *rtau_ = THTensor_(new)(); THTensor *rr__ = THTensor_(new)(); THTensor_(geqrf)(ra_, rtau_, a); THTensor_(resize2d)(rr__, k, ra_->size[1]); THTensor_(narrow)(rr__, ra_, 0, 0, k); THTensor_(triu)(rr_, rr__, 0); THTensor_(resize2d)(rq_, ra_->size[0], k); THTensor_(orgqr)(rq_, ra_, rtau_); THTensor_(narrow)(rq_, rq_, 1, 0, k); THTensor_(free)(ra_); THTensor_(free)(rtau_); THTensor_(free)(rr__); } /* The geqrf function does the main work of QR-decomposing a matrix. However, rather than producing a Q matrix directly, it produces a sequence of elementary reflectors which may later be composed to construct Q - for example with the orgqr function, below. Args: * `ra_` - Result matrix which will contain: i) The elements of R, on and above the diagonal. ii) Directions of the reflectors implicitly defining Q. * `rtau_` - Result tensor which will contain the magnitudes of the reflectors implicitly defining Q. * `a` - Input matrix, to decompose. If NULL, `ra_` is used as input. For further details, please see the LAPACK documentation. */ void THTensor_(geqrf)(THTensor *ra_, THTensor *rtau_, THTensor *a) { if (a == NULL) ra_ = a; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THTensor *ra__ = NULL; /* Prepare the input for LAPACK, making a copy if necessary. */ ra__ = THTensor_(cloneColumnMajor)(ra_, a); int m = ra__->size[0]; int n = ra__->size[1]; int k = (m < n ? m : n); int lda = m; THTensor_(resize1d)(rtau_, k); /* Dry-run to query the suggested size of the workspace. */ int info = 0; real wkopt = 0; THLapack_(geqrf)(m, n, THTensor_(data)(ra__), lda, THTensor_(data)(rtau_), &wkopt, -1, &info); /* Allocate the workspace and call LAPACK to do the real work. */ int lwork = (int)wkopt; THTensor *work = THTensor_(newWithSize1d)(lwork); THLapack_(geqrf)(m, n, THTensor_(data)(ra__), lda, THTensor_(data)(rtau_), THTensor_(data)(work), lwork, &info); THLapackCheckWithCleanup("Lapack Error %s : unknown Lapack error. info = %i", THCleanup( THTensor_(free)(ra__); THTensor_(free)(work);), "geqrf", info,""); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(free)(work); } /* The orgqr function allows reconstruction of a matrix Q with orthogonal columns, from a sequence of elementary reflectors, such as is produced by the geqrf function. Args: * `ra_` - result Tensor, which will contain the matrix Q. * `a` - input Tensor, which should be a matrix with the directions of the elementary reflectors below the diagonal. If NULL, `ra_` is used as input. * `tau` - input Tensor, containing the magnitudes of the elementary reflectors. For further details, please see the LAPACK documentation. */ void THTensor_(orgqr)(THTensor *ra_, THTensor *a, THTensor *tau) { if (a == NULL) a = ra_; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THTensor *ra__ = NULL; ra__ = THTensor_(cloneColumnMajor)(ra_, a); int m = ra__->size[0]; int n = ra__->size[1]; int k = tau->size[0]; int lda = m; /* Dry-run to query the suggested size of the workspace. */ int info = 0; real wkopt = 0; THLapack_(orgqr)(m, k, k, THTensor_(data)(ra__), lda, THTensor_(data)(tau), &wkopt, -1, &info); /* Allocate the workspace and call LAPACK to do the real work. */ int lwork = (int)wkopt; THTensor *work = THTensor_(newWithSize1d)(lwork); THLapack_(orgqr)(m, k, k, THTensor_(data)(ra__), lda, THTensor_(data)(tau), THTensor_(data)(work), lwork, &info); THLapackCheckWithCleanup(" Lapack Error %s : unknown Lapack error. info = %i", THCleanup( THTensor_(free)(ra__); THTensor_(free)(work);), "orgqr", info,""); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(free)(work); } /* The ormqr function multiplies Q with another matrix from a sequence of elementary reflectors, such as is produced by the geqrf function. Args: * `ra_` - result Tensor, which will contain the matrix Q' c. * `a` - input Tensor, which should be a matrix with the directions of the elementary reflectors below the diagonal. If NULL, `ra_` is used as input. * `tau` - input Tensor, containing the magnitudes of the elementary reflectors. * `c` - input Tensor, containing the matrix to be multiplied. * `side` - char, determining whether c is left- or right-multiplied with Q. * `trans` - char, determining whether to transpose Q before multiplying. For further details, please see the LAPACK documentation. */ void THTensor_(ormqr)(THTensor *ra_, THTensor *a, THTensor *tau, THTensor *c, const char *side, const char *trans) { if (a == NULL) a = ra_; THArgCheck(a->nDimension == 2, 1, "A should be 2 dimensional"); THTensor *ra__ = NULL; ra__ = THTensor_(cloneColumnMajor)(ra_, c); int m = c->size[0]; int n = c->size[1]; int k = tau->size[0]; int lda; if (*side == 'L') { lda = m; } else { lda = n; } int ldc = m; /* Dry-run to query the suggested size of the workspace. */ int info = 0; real wkopt = 0; THLapack_(ormqr)(side[0], trans[0], m, n, k, THTensor_(data)(a), lda, THTensor_(data)(tau), THTensor_(data)(ra__), ldc, &wkopt, -1, &info); /* Allocate the workspace and call LAPACK to do the real work. */ int lwork = (int)wkopt; THTensor *work = THTensor_(newWithSize1d)(lwork); THLapack_(ormqr)(side[0], trans[0], m, n, k, THTensor_(data)(a), lda, THTensor_(data)(tau), THTensor_(data)(ra__), ldc, THTensor_(data)(work), lwork, &info); THLapackCheckWithCleanup(" Lapack Error %s : unknown Lapack error. info = %i", THCleanup( THTensor_(free)(ra__); THTensor_(free)(work);), "ormqr", info,""); THTensor_(freeCopyTo)(ra__, ra_); THTensor_(free)(work); } void THTensor_(btrifact)(THTensor *ra_, THIntTensor *rpivots_, THIntTensor *rinfo_, int pivot, THTensor *a) { THArgCheck(THTensor_(nDimension)(a) == 3, 1, "expected 3D tensor, got %dD", THTensor_(nDimension)(a)); if (!pivot) { THError("btrifact without pivoting is not implemented on the CPU"); } if (ra_ != a) { THTensor_(resizeAs)(ra_, a); THTensor_(copy)(ra_, a); } int m = a->size[1]; int n = a->size[2]; if (m != n) { THError("btrifact is only implemented for square matrices"); } long num_batches = THTensor_(size)(a, 0); THTensor *ra__; int lda; if (ra_->stride[1] == 1) { // column ordered, what BLAS wants lda = ra_->stride[2]; ra__ = ra_; } else { // not column ordered, need to make it such (requires copy) THTensor *transp_r_ = THTensor_(newTranspose)(ra_, 1, 2); ra__ = THTensor_(newClone)(transp_r_); THTensor_(free)(transp_r_); THTensor_(transpose)(ra__, NULL, 1, 2); lda = ra__->stride[2]; } THTensor *ai = THTensor_(new)(); THTensor *rai = THTensor_(new)(); THIntTensor *rpivoti = THIntTensor_new(); int info = 0; int *info_ptr = &info; if (rinfo_) { THIntTensor_resize1d(rinfo_, num_batches); info_ptr = THIntTensor_data(rinfo_); } THIntTensor_resize2d(rpivots_, num_batches, n); long batch = 0; for (; batch < num_batches; ++batch) { THTensor_(select)(ai, a, 0, batch); THTensor_(select)(rai, ra__, 0, batch); THIntTensor_select(rpivoti, rpivots_, 0, batch); THLapack_(getrf)(n, n, THTensor_(data)(rai), lda, THIntTensor_data(rpivoti), info_ptr); if (rinfo_) { info_ptr++; } else if (info != 0) { break; } } THTensor_(free)(ai); THTensor_(free)(rai); THIntTensor_free(rpivoti); if (ra__ != ra_) { THTensor_(freeCopyTo)(ra__, ra_); } if (!rinfo_ && info != 0) { THError("failed to factorize batch element %ld (info == %d)", batch, info); } } void THTensor_(btrisolve)(THTensor *rb_, THTensor *b, THTensor *atf, THIntTensor *pivots) { THArgCheck(THTensor_(nDimension)(atf) == 3, 1, "expected 3D tensor, got %dD", THTensor_(nDimension)(atf)); THArgCheck(THTensor_(nDimension)(b) == 3 || THTensor_(nDimension)(b) == 2, 4, "expected 2D or 3D tensor"); THArgCheck(THTensor_(size)(atf, 0) == THTensor_(size)(b, 0), 3, "number of batches must be equal"); THArgCheck(THTensor_(size)(atf, 1) == THTensor_(size)(atf, 2), 3, "A matrices must be square"); THArgCheck(THTensor_(size)(atf, 1) == THTensor_(size)(b, 1), 3, "dimensions of A and b must be equal"); if (rb_ != b) { THTensor_(resizeAs)(rb_, b); THTensor_(copy)(rb_, b); } long num_batches = atf->size[0]; long n = atf->size[1]; int nrhs = rb_->nDimension > 2 ? rb_->size[2] : 1; int lda, ldb; THTensor *atf_; THTensor *rb__; // correct ordering of A if (atf->stride[1] == 1) { // column ordered, what BLAS wants lda = atf->stride[2]; atf_ = atf; } else { // not column ordered, need to make it such (requires copy) // it would be nice if we could use the op(A) flags to automatically // transpose A if needed, but this leads to unpredictable behavior if the // user clones A_tf later with a different ordering THTensor *transp_r_ = THTensor_(newTranspose)(atf, 1, 2); atf_ = THTensor_(newClone)(transp_r_); THTensor_(free)(transp_r_); THTensor_(transpose)(atf_, NULL, 1, 2); lda = atf_->stride[2]; } // correct ordering of B if (rb_->stride[1] == 1) { // column ordered if (rb_->nDimension == 2 || rb_->size[2] == 1) { ldb = n; } else { ldb = rb_->stride[2]; } rb__ = rb_; } else { // make column ordered if (rb_->nDimension > 2) { THTensor *transp_r_ = THTensor_(newTranspose)(rb_, 1, 2); rb__ = THTensor_(newClone)(transp_r_); THTensor_(free)(transp_r_); THTensor_(transpose)(rb__, NULL, 1, 2); ldb = rb__->stride[2]; } else { rb__ = THTensor_(newClone)(rb_); ldb = n; } } THTensor *ai = THTensor_(new)(); THTensor *rbi = THTensor_(new)(); THIntTensor *pivoti = THIntTensor_new(); if (!THIntTensor_isContiguous(pivots)) { THError("Error: rpivots_ is not contiguous."); } for (long batch = 0; batch < num_batches; ++batch) { THTensor_(select)(ai, atf_, 0, batch); THTensor_(select)(rbi, rb__, 0, batch); THIntTensor_select(pivoti, pivots, 0, batch); #if defined(TH_REAL_IS_FLOAT) || defined(TH_REAL_IS_DOUBLE) int info; THLapack_(getrs)('N', n, nrhs, THTensor_(data)(ai), lda, THIntTensor_data(pivoti), THTensor_(data)(rbi), ldb, &info); if (info != 0) { THError("Error: Nonzero info."); } #else THError("Unimplemented"); #endif } THTensor_(free)(ai); THTensor_(free)(rbi); THIntTensor_free(pivoti); if (atf_ != atf) { THTensor_(free)(atf_); } if (rb__ != rb_) { THTensor_(freeCopyTo)(rb__, rb_); } } #endif
the_stack_data/218892113.c
/* * ===================================================================================== * * Filename: 10.c * * Description: * * Version: 1.0 * Created: 02/03/2017 12:56:47 * Revision: none * Compiler: gcc * * Author: OLGA OLEKSYUK (olgawow), [email protected] * Organization: * * ===================================================================================== */ #include<stdio.h> #include<string.h> void gotoxy(int x,int y) { printf("%c[%d;%df",0x1B,y,x); } void clr() { system("clear"); } int main() { int i = 0; int number; clr(); while (i < 10) { printf("\nEnter number: "); scanf("%d", &number); gotoxy(10, 10); printf("-----\n"); printf("| %d | ", i * number); i++; }; }
the_stack_data/54441.c
/* * pinyin.c */ #define HANZI_START 19968 #define HANZI_COUNT 20902 static char firstLetterArray[HANZI_COUNT] = "ydkqsxnwzssxjbymgcczqpssqbycdscdqldylybssjgyqzjjfgcclzznwdwzjljpfyynnjjtmynzwzhflzppqhgccyynmjqyxxgd" "nnsnsjnjnsnnmlnrxyfsngnnnnqzggllyjlnyzssecykyyhqwjssggyxyqyjtwktjhychmnxjtlhjyqbyxdldwrrjnwysrldzjpc" "bzjjbrcfslnczstzfxxchtrqggddlyccssymmrjcyqzpwwjjyfcrwfdfzqpyddwyxkyjawjffxjbcftzyhhycyswccyxsclcxxwz" "cxnbgnnxbxlzsqsbsjpysazdhmdzbqbscwdzzyytzhbtsyyfzgntnxjywqnknphhlxgybfmjnbjhhgqtjcysxstkzglyckglysmz" "xyalmeldccxgzyrjxjzlnjzcqkcnnjwhjczccqljststbnhbtyxceqxkkwjyflzqlyhjxspsfxlmpbysxxxytccnylllsjxfhjxp" "jbtffyabyxbcczbzyclwlczggbtssmdtjcxpthyqtgjjxcjfzkjzjqnlzwlslhdzbwjncjzyzsqnycqynzcjjwybrtwpyftwexcs" "kdzctbyhyzqyyjxzcfbzzmjyxxsdczottbzljwfckscsxfyrlrygmbdthjxsqjccsbxyytswfbjdztnbcnzlcyzzpsacyzzsqqcs" "hzqydxlbpjllmqxqydzxsqjtzpxlcglqdcwzfhctdjjsfxjejjtlbgxsxjmyjjqpfzasyjnsydjxkjcdjsznbartcclnjqmwnqnc" "lllkbdbzzsyhqcltwlccrshllzntylnewyzyxczxxgdkdmtcedejtsyyssdqdfmxdbjlkrwnqlybglxnlgtgxbqjdznyjsjyjcjm" "rnymgrcjczgjmzmgxmmryxkjnymsgmzzymknfxmbdtgfbhcjhkylpfmdxlxjjsmsqgzsjlqdldgjycalcmzcsdjllnxdjffffjcn" "fnnffpfkhkgdpqxktacjdhhzdddrrcfqyjkqccwjdxhwjlyllzgcfcqjsmlzpbjjblsbcjggdckkdezsqcckjgcgkdjtjllzycxk" "lqccgjcltfpcqczgwbjdqyzjjbyjhsjddwgfsjgzkcjctllfspkjgqjhzzljplgjgjjthjjyjzccmlzlyqbgjwmljkxzdznjqsyz" "mljlljkywxmkjlhskjhbmclyymkxjqlbmllkmdxxkwyxwslmlpsjqqjqxyqfjtjdxmxxllcrqbsyjbgwynnggbcnxpjtgpapfgdj" "qbhbncfjyzjkjkhxqfgqckfhygkhdkllsdjqxpqyaybnqsxqnszswhbsxwhxwbzzxdmndjbsbkbbzklylxgwxjjwaqzmywsjqlsj" "xxjqwjeqxnchetlzalyyyszzpnkyzcptlshtzcfycyxyljsdcjqagyslcllyyysslqqqnldxzsccscadycjysfsgbfrsszqsbxjp" "sjysdrckgjlgtkzjzbdktcsyqpyhstcldjnhmymcgxyzhjdctmhltxzhylamoxyjcltyfbqqjpfbdfehthsqhzywwcncxcdwhowg" "yjlegmdqcwgfjhcsntmydolbygnqwesqpwnmlrydzszzlyqpzgcwxhnxpyxshmdqjgztdppbfbhzhhjyfdzwkgkzbldnzsxhqeeg" "zxylzmmzyjzgszxkhkhtxexxgylyapsthxdwhzydpxagkydxbhnhnkdnjnmyhylpmgecslnzhkxxlbzzlbmlsfbhhgsgyyggbhsc" "yajtxglxtzmcwzydqdqmngdnllszhngjzwfyhqswscelqajynytlsxthaznkzzsdhlaxxtwwcjhqqtddwzbcchyqzflxpslzqgpz" "sznglydqtbdlxntctajdkywnsyzljhhdzckryyzywmhychhhxhjkzwsxhdnxlyscqydpslyzwmypnkxyjlkchtyhaxqsyshxasmc" "hkdscrsgjpwqsgzjlwwschsjhsqnhnsngndantbaalczmsstdqjcjktscjnxplggxhhgoxzcxpdmmhldgtybynjmxhmrzplxjzck" "zxshflqxxcdhxwzpckczcdytcjyxqhlxdhypjqxnlsyydzozjnhhqezysjyayxkypdgxddnsppyzndhthrhxydpcjjhtcnnctlhb" "ynyhmhzllnnxmylllmdcppxhmxdkycyrdltxjchhznxclcclylnzsxnjzzlnnnnwhyqsnjhxynttdkyjpychhyegkcwtwlgjrlgg" "tgtygyhpyhylqyqgcwyqkpyyettttlhyylltyttsylnyzwgywgpydqqzzdqnnkcqnmjjzzbxtqfjkdffbtkhzkbxdjjkdjjtlbwf" "zpptkqtztgpdwntpjyfalqmkgxbcclzfhzcllllanpnxtjklcclgyhdzfgyddgcyyfgydxkssendhykdndknnaxxhbpbyyhxccga" "pfqyjjdmlxcsjzllpcnbsxgjyndybwjspcwjlzkzddtacsbkzdyzypjzqsjnkktknjdjgyepgtlnyqnacdntcyhblgdzhbbydmjr" "egkzyheyybjmcdtafzjzhgcjnlghldwxjjkytcyksssmtwcttqzlpbszdtwcxgzagyktywxlnlcpbclloqmmzsslcmbjcsdzkydc" "zjgqjdsmcytzqqlnzqzxssbpkdfqmddzzsddtdmfhtdycnaqjqkypbdjyyxtljhdrqxlmhkydhrnlklytwhllrllrcxylbnsrnzz" "symqzzhhkyhxksmzsyzgcxfbnbsqlfzxxnnxkxwymsddyqnggqmmyhcdzttfgyyhgsbttybykjdnkyjbelhdypjqnfxfdnkzhqks" "byjtzbxhfdsbdaswpawajldyjsfhblcnndnqjtjnchxfjsrfwhzfmdrfjyxwzpdjkzyjympcyznynxfbytfyfwygdbnzzzdnytxz" "emmqbsqehxfznbmflzzsrsyqjgsxwzjsprytjsjgskjjgljjynzjjxhgjkymlpyyycxycgqzswhwlyrjlpxslcxmnsmwklcdnkny" "npsjszhdzeptxmwywxyysywlxjqcqxzdclaeelmcpjpclwbxsqhfwrtfnjtnqjhjqdxhwlbyccfjlylkyynldxnhycstyywncjtx" "ywtrmdrqnwqcmfjdxzmhmayxnwmyzqtxtlmrspwwjhanbxtgzypxyyrrclmpamgkqjszycymyjsnxtplnbappypylxmyzkynldgy" "jzcchnlmzhhanqnbgwqtzmxxmllhgdzxnhxhrxycjmffxywcfsbssqlhnndycannmtcjcypnxnytycnnymnmsxndlylysljnlxys" "sqmllyzlzjjjkyzzcsfbzxxmstbjgnxnchlsnmcjscyznfzlxbrnnnylmnrtgzqysatswryhyjzmgdhzgzdwybsscskxsyhytsxg" "cqgxzzbhyxjscrhmkkbsczjyjymkqhzjfnbhmqhysnjnzybknqmcjgqhwlsnzswxkhljhyybqcbfcdsxdldspfzfskjjzwzxsddx" "jseeegjscssygclxxnwwyllymwwwgydkzjggggggsycknjwnjpcxbjjtqtjwdsspjxcxnzxnmelptfsxtllxcljxjjljsxctnswx" "lennlyqrwhsycsqnybyaywjejqfwqcqqcjqgxaldbzzyjgkgxbltqyfxjltpydkyqhpmatlcndnkxmtxynhklefxdllegqtymsaw" "hzmljtkynxlyjzljeeyybqqffnlyxhdsctgjhxywlkllxqkcctnhjlqmkkzgcyygllljdcgydhzwypysjbzjdzgyzzhywyfqdtyz" "szyezklymgjjhtsmqwyzljyywzcsrkqyqltdxwcdrjalwsqzwbdcqyncjnnszjlncdcdtlzzzacqqzzddxyblxcbqjylzllljddz" "jgyqyjzyxnyyyexjxksdaznyrdlzyyynjlslldyxjcykywnqcclddnyyynycgczhjxcclgzqjgnwnncqqjysbzzxyjxjnxjfzbsb" "dsfnsfpzxhdwztdmpptflzzbzdmyypqjrsdzsqzsqxbdgcpzswdwcsqzgmdhzxmwwfybpngphdmjthzsmmbgzmbzjcfzhfcbbnmq" "dfmbcmcjxlgpnjbbxgyhyyjgptzgzmqbqdcgybjxlwnkydpdymgcftpfxzxdzxtgkptybbclbjaskytssqyymscxfjhhlslls" "jpqjjqaklyldlycctsxmcwfgngbqxllllnyxtyltyxytdpjhnhgnkbyqnfjyyzbyyessessgdyhfhwtcqbsdzjtfdmxhcnjzymqw" "srxjdzjqbdqbbsdjgnfbknbxdkqhmkwjjjgdllthzhhyyyyhhsxztyyyccbdbpypzyccztjpzywcbdlfwzcwjdxxhyhlhwczxjtc" "nlcdpxnqczczlyxjjcjbhfxwpywxzpcdzzbdccjwjhmlxbqxxbylrddgjrrctttgqdczwmxfytmmzcwjwxyywzzkybzcccttqnhx" "nwxxkhkfhtswoccjybcmpzzykbnnzpbthhjdlszddytyfjpxyngfxbyqxzbhxcpxxtnzdnnycnxsxlhkmzxlthdhkghxxsshqyhh" "cjyxglhzxcxnhekdtgqxqypkdhentykcnymyyjmkqyyyjxzlthhqtbyqhxbmyhsqckwwyllhcyylnneqxqwmcfbdccmljggxdqkt" "lxkknqcdgcjwyjjlyhhqyttnwchhxcxwherzjydjccdbqcdgdnyxzdhcqrxcbhztqcbxwgqwyybxhmbymykdyecmqkyaqyngyzsl" "fnkkqgyssqyshngjctxkzycssbkyxhyylstycxqthysmnscpmmgcccccmnztasmgqzjhklosjylswtmqzyqkdzljqqyplzycztcq" "qpbbcjzclpkhqcyyxxdtdddsjcxffllchqxmjlwcjcxtspycxndtjshjwhdqqqckxyamylsjhmlalygxcyydmamdqmlmcznnyybz" "xkyflmcncmlhxrcjjhsylnmtjggzgywjxsrxcwjgjqhqzdqjdcjjskjkgdzcgjjyjylxzxxcdqhhheslmhlfsbdjsyyshfyssczq" "lpbdrfnztzdkykhsccgkwtqzckmsynbcrxqbjyfaxpzzedzcjykbcjwhyjbqzzywnyszptdkzpfpbaztklqnhbbzptpptyzzybhn" "ydcpzmmcycqmcjfzzdcmnlfpbplngqjtbttajzpzbbdnjkljqylnbzqhksjznggqstzkcxchpzsnbcgzkddzqanzgjkdrtlzldwj" "njzlywtxndjzjhxnatncbgtzcsskmljpjytsnwxcfjwjjtkhtzplbhsnjssyjbhbjyzlstlsbjhdnwqpslmmfbjdwajyzccjtbnn" "nzwxxcdslqgdsdpdzgjtqqpsqlyyjzlgyhsdlctcbjtktyczjtqkbsjlgnnzdncsgpynjzjjyyknhrpwszxmtncszzyshbyhyzax" "ywkcjtllckjjtjhgcssxyqyczbynnlwqcglzgjgqyqcczssbcrbcskydznxjsqgxssjmecnstjtpbdlthzwxqwqczexnqczgwesg" "ssbybstscslccgbfsdqnzlccglllzghzcthcnmjgyzazcmsksstzmmzckbjygqljyjppldxrkzyxccsnhshhdznlzhzjjcddcbcj" "xlbfqbczztpqdnnxljcthqzjgylklszzpcjdscqjhjqkdxgpbajynnsmjtzdxlcjyryynhjbngzjkmjxltbsllrzpylssznxjhll" "hyllqqzqlsymrcncxsljmlzltzldwdjjllnzggqxppskyggggbfzbdkmwggcxmcgdxjmcjsdycabxjdlnbcddygskydqdxdjjyxh" "saqazdzfslqxxjnqzylblxxwxqqzbjzlfbblylwdsljhxjyzjwtdjcyfqzqzzdzsxzzqlzcdzfxhwspynpqzmlpplffxjjnzzyls" "jnyqzfpfzgsywjjjhrdjzzxtxxglghtdxcskyswmmtcwybazbjkshfhgcxmhfqhyxxyzftsjyzbxyxpzlchmzmbxhzzssyfdmncw" "dabazlxktcshhxkxjjzjsthygxsxyyhhhjwxkzxssbzzwhhhcwtzzzpjxsyxqqjgzyzawllcwxznxgyxyhfmkhydwsqmnjnaycys" "pmjkgwcqhylajgmzxhmmcnzhbhxclxdjpltxyjkdyylttxfqzhyxxsjbjnayrsmxyplckdnyhlxrlnllstycyyqygzhhsccsmcct" "zcxhyqfpyyrpbflfqnntszlljmhwtcjqyzwtlnmlmdwmbzzsnzrbpdddlqjjbxtcsnzqqygwcsxfwzlxccrszdzmcyggdyqsgtnn" "nlsmymmsyhfbjdgyxccpshxczcsbsjyygjmpbwaffyfnxhydxzylremzgzzyndsznlljcsqfnxxkptxzgxjjgbmyyssnbtylbnlh" "bfzdcyfbmgqrrmzszxysjtznnydzzcdgnjafjbdknzblczszpsgcycjszlmnrznbzzldlnllysxsqzqlcxzlsgkbrxbrbzcycxzj" "zeeyfgklzlnyhgzcgzlfjhgtgwkraajyzkzqtsshjjxdzyznynnzyrzdqqhgjzxsszbtkjbbfrtjxllfqwjgclqtymblpzdxtzag" "bdhzzrbgjhwnjtjxlkscfsmwlldcysjtxkzscfwjlbnntzlljzllqblcqmqqcgcdfpbphzczjlpyyghdtgwdxfczqyyyqysrclqz" "fklzzzgffcqnwglhjycjjczlqzzyjbjzzbpdcsnnjgxdqnknlznnnnpsntsdyfwwdjzjysxyyczcyhzwbbyhxrylybhkjksfxtjj" "mmchhlltnyymsxxyzpdjjycsycwmdjjkqyrhllngpngtlyycljnnnxjyzfnmlrgjjtyzbsyzmsjyjhgfzqmsyxrszcytlrtqzsst" "kxgqkgsptgxdnjsgcqcqhmxggztqydjjznlbznxqlhyqgggthqscbyhjhhkyygkggcmjdzllcclxqsftgjslllmlcskctbljszsz" "mmnytpzsxqhjcnnqnyexzqzcpshkzzyzxxdfgmwqrllqxrfztlystctmjcsjjthjnxtnrztzfqrhcgllgcnnnnjdnlnnytsjtlny" "xsszxcgjzyqpylfhdjsbbdczgjjjqzjqdybssllcmyttmqnbhjqmnygjyeqyqmzgcjkpdcnmyzgqllslnclmholzgdylfzslncnz" "lylzcjeshnyllnxnjxlyjyyyxnbcljsswcqqnnyllzldjnllzllbnylnqchxyyqoxccqkyjxxxyklksxeyqhcqkkkkcsnyxxyqxy" "gwtjohthxpxxhsnlcykychzzcbwqbbwjqcscszsslcylgddsjzmmymcytsdsxxscjpqqsqylyfzychdjynywcbtjsydchcyddjlb" "djjsodzyqyskkyxdhhgqjyohdyxwgmmmazdybbbppbcmnnpnjzsmtxerxjmhqdntpjdcbsnmssythjtslmltrcplzszmlqdsdmjm" "qpnqdxcfrnnfsdqqyxhyaykqyddlqyyysszbydslntfgtzqbzmchdhczcwfdxtmqqsphqwwxsrgjcwnntzcqmgwqjrjhtqjbbgwz" "fxjhnqfxxqywyyhyscdydhhqmrmtmwctbszppzzglmzfollcfwhmmsjzttdhlmyffytzzgzyskjjxqyjzqbhmbzclyghgfmshpcf" "zsnclpbqsnjyzslxxfpmtyjygbxlldlxpzjyzjyhhzcywhjylsjexfszzywxkzjlnadymlymqjpwxxhxsktqjezrpxxzghmhwqpw" "qlyjjqjjzszcnhjlchhnxjlqwzjhbmzyxbdhhypylhlhlgfwlcfyytlhjjcwmscpxstkpnhjxsntyxxtestjctlsslstdlllwwyh" "dnrjzsfgxssyczykwhtdhwjglhtzdqdjzxxqgghltzphcsqfclnjtclzpfstpdynylgmjllycqhynspchylhqyqtmzymbywrfqyk" "jsyslzdnjmpxyyssrhzjnyqtqdfzbwwdwwrxcwggyhxmkmyyyhmxmzhnksepmlqqmtcwctmxmxjpjjhfxyyzsjzhtybmstsyjznq" "jnytlhynbyqclcycnzwsmylknjxlggnnpjgtysylymzskttwlgsmzsylmpwlcwxwqcssyzsyxyrhssntsrwpccpwcmhdhhxzdzyf" "jhgzttsbjhgyglzysmyclllxbtyxhbbzjkssdmalhhycfygmqypjyjqxjllljgclzgqlycjcctotyxmtmshllwlqfxymzmklpszz" "cxhkjyclctyjcyhxsgyxnnxlzwpyjpxhjwpjpwxqqxlxsdhmrslzzydwdtcxknstzshbsccstplwsscjchjlcgchssphylhfhhxj" "sxallnylmzdhzxylsxlmzykcldyahlcmddyspjtqjzlngjfsjshctsdszlblmssmnyymjqbjhrzwtyydchjljapzwbgqxbkfnbjd" "llllyylsjydwhxpsbcmljpscgbhxlqhyrljxyswxhhzlldfhlnnymjljyflyjycdrjlfsyzfsllcqyqfgqyhnszlylmdtdjcnhbz" "llnwlqxygyyhbmgdhxxnhlzzjzxczzzcyqzfngwpylcpkpykpmclgkdgxzgxwqbdxzzkzfbddlzxjtpjpttbythzzdwslcpnhslt" "jxxqlhyxxxywzyswttzkhlxzxzpyhgzhknfsyhntjrnxfjcpjztwhplshfcrhnslxxjxxyhzqdxqwnnhyhmjdbflkhcxcwhjfyjc" "fpqcxqxzyyyjygrpynscsnnnnchkzdyhflxxhjjbyzwttxnncyjjymswyxqrmhxzwfqsylznggbhyxnnbwttcsybhxxwxyhhxyxn" "knyxmlywrnnqlxbbcljsylfsytjzyhyzawlhorjmnsczjxxxyxchcyqryxqzddsjfslyltsffyxlmtyjmnnyyyxltzcsxqclhzxl" "wyxzhnnlrxkxjcdyhlbrlmbrdlaxksnlljlyxxlynrylcjtgncmtlzllcyzlpzpzyawnjjfybdyyzsepckzzqdqpbpsjpdyttbdb" "bbyndycncpjmtmlrmfmmrwyfbsjgygsmdqqqztxmkqwgxllpjgzbqrdjjjfpkjkcxbljmswldtsjxldlppbxcwkcqqbfqbccajzg" "mykbhyhhzykndqzybpjnspxthlfpnsygyjdbgxnhhjhzjhstrstldxskzysybmxjlxyslbzyslzxjhfybqnbylljqkygzmcyzzym" "ccslnlhzhwfwyxzmwyxtynxjhbyymcysbmhysmydyshnyzchmjjmzcaahcbjbbhblytylsxsnxgjdhkxxtxxnbhnmlngsltxmrhn" "lxqqxmzllyswqgdlbjhdcgjyqyymhwfmjybbbyjyjwjmdpwhxqldyapdfxxbcgjspckrssyzjmslbzzjfljjjlgxzgyxyxlszqkx" "bexyxhgcxbpndyhwectwwcjmbtxchxyqqllxflyxlljlssnwdbzcmyjclwswdczpchqekcqbwlcgydblqppqzqfnqdjhymmcxtxd" "rmzwrhxcjzylqxdyynhyyhrslnrsywwjjymtltllgtqcjzyabtckzcjyccqlysqxalmzynywlwdnzxqdllqshgpjfjljnjabcqzd" "jgthhsstnyjfbswzlxjxrhgldlzrlzqzgsllllzlymxxgdzhgbdphzpbrlwnjqbpfdwonnnhlypcnjccndmbcpbzzncyqxldomzb" "lzwpdwyygdstthcsqsccrsssyslfybnntyjszdfndpdhtqzmbqlxlcmyffgtjjqwftmnpjwdnlbzcmmcngbdzlqlpnfhyymjylsd" "chdcjwjcctljcldtljjcbddpndsszycndbjlggjzxsxnlycybjjxxcbylzcfzppgkcxqdzfztjjfjdjxzbnzyjqctyjwhdyczhym" "djxttmpxsplzcdwslshxypzgtfmlcjtacbbmgdewycyzxdszjyhflystygwhkjyylsjcxgywjcbllcsnddbtzbsclyzczzssqdll" "mjyyhfllqllxfdyhabxggnywyypllsdldllbjcyxjznlhljdxyyqytdlllbngpfdfbbqbzzmdpjhgclgmjjpgaehhbwcqxajhhhz" "chxyphjaxhlphjpgpzjqcqzgjjzzgzdmqyybzzphyhybwhazyjhykfgdpfqsdlzmljxjpgalxzdaglmdgxmmzqwtxdxxpfdmmssy" "mpfmdmmkxksyzyshdzkjsysmmzzzmdydyzzczxbmlstmdyemxckjmztyymzmzzmsshhdccjewxxkljsthwlsqlyjzllsjssdppmh" "nlgjczyhmxxhgncjmdhxtkgrmxfwmckmwkdcksxqmmmszzydkmsclcmpcjmhrpxqpzdsslcxkyxtwlkjyahzjgzjwcjnxyhmmbml" "gjxmhlmlgmxctkzmjlyscjsyszhsyjzjcdajzhbsdqjzgwtkqxfkdmsdjlfmnhkzqkjfeypzyszcdpynffmzqykttdzzefmzlbnp" "plplpbpszalltnlkckqzkgenjlwalkxydpxnhsxqnwqnkxqclhyxxmlnccwlymqyckynnlcjnszkpyzkcqzqljbdmdjhlasqlbyd" "wqlwdgbqcryddztjybkbwszdxdtnpjdtcnqnfxqqmgnseclstbhpwslctxxlpwydzklnqgzcqapllkqcylbqmqczqcnjslqzdjxl" "hzssccmlyxwtpzgxzjgzgsjzgkddhtqggzllbjdzlsbzhyxyzhzfywxytymsdnzzyjgtcmtnxqyxjscxhslnndlrytzlryylxqht" "xsrtzcgyxbnqqzfhykmzjbzymkbpnlyzpblmcnqyzzzsjztjctzhhyzzjrdyzhnfxklfzslkgjtctssyllgzrzbbjzzklpkbczys" "nnyxbjfbnjzzxcdwlzyjxzzdjjgggrsnjkmsmzjlsjywqsnyhqjsxpjztnlsnshrnynjtwchglbnrjlzxwjqxqkysjycztlqzybb" "ybyzjqdwgyzcytjcjxckcwdkkzxsnkdnywwyyjqyytlytdjlxwkcjnklccpzcqqdzzqlcsfqchqqgssmjzzllbjjzysjhtsjdysj" "qjpdszcdchjkjzzlpycgmzndjxbsjzzsyzyhgxcpbjydssxdzncglqmbtsfcbfdzdlznfgfjgfsmpnjqlnblgqcyyxbqgdjjqsrf" "kztjdhczklbsdzcfytplljgjhtxzcsszzxstjygkgckgynqxjplzbbbgcgyjzgczqszlbjlsjfzgkqqjcgycjbzqtldxrjnbsxxp" "zshszycfwdsjjhxmfczpfzhqhqmqnknlyhtycgfrzgnqxcgpdlbzcsczqlljblhbdcypscppdymzzxgyhckcpzjgslzlnscnsldl" "xbmsdlddfjmkdqdhslzxlsznpqpgjdlybdskgqlbzlnlkyyhzttmcjnqtzzfszqktlljtyyllnllqyzqlbdzlslyyzxmdfszsnxl" "xznczqnbbwskrfbcylctnblgjpmczzlstlxshtzcyzlzbnfmqnlxflcjlyljqcbclzjgnsstbrmhxzhjzclxfnbgxgtqncztmsfz" "kjmssncljkbhszjntnlzdntlmmjxgzjyjczxyhyhwrwwqnztnfjscpyshzjfyrdjsfscjzbjfzqzchzlxfxsbzqlzsgyftzdcszx" "zjbjpszkjrhxjzcgbjkhcggtxkjqglxbxfgtrtylxqxhdtsjxhjzjjcmzlcqsbtxwqgxtxxhxftsdkfjhzyjfjxnzldlllcqsqqz" "qwqxswqtwgwbzcgcllqzbclmqjtzgzyzxljfrmyzflxnsnxxjkxrmjdzdmmyxbsqbhgzmwfwygmjlzbyytgzyccdjyzxsngnyjyz" "nbgpzjcqsyxsxrtfyzgrhztxszzthcbfclsyxzlzqmzlmplmxzjssfsbysmzqhxxnxrxhqzzzsslyflczjrcrxhhzxqndshxsjjh" "qcjjbcynsysxjbqjpxzqplmlxzkyxlxcnlcycxxzzlxdlllmjyhzxhyjwkjrwyhcpsgnrzlfzwfzznsxgxflzsxzzzbfcsyjdbrj" "krdhhjxjljjtgxjxxstjtjxlyxqfcsgswmsbctlqzzwlzzkxjmltmjyhsddbxgzhdlbmyjfrzfcgclyjbpmlysmsxlszjqqhjzfx" "gfqfqbphngyyqxgztnqwyltlgwgwwhnlfmfgzjmgmgbgtjflyzzgzyzaflsspmlbflcwbjztljjmzlpjjlymqtmyyyfbgygqzgly" "zdxqyxrqqqhsxyyqxygjtyxfsfsllgnqcygycwfhcccfxpylypllzqxxxxxqqhhsshjzcftsczjxspzwhhhhhapylqnlpqafyhxd" "ylnkmzqgggddesrenzltzgchyppcsqjjhclljtolnjpzljlhymhezdydsqycddhgznndzclzywllznteydgnlhslpjjbdgwxpcnn" "tycklkclwkllcasstknzdnnjttlyyzssysszzryljqkcgdhhyrxrzydgrgcwcgzqffbppjfzynakrgywyjpqxxfkjtszzxswzddf" "bbqtbgtzkznpzfpzxzpjszbmqhkyyxyldkljnypkyghgdzjxxeaxpnznctzcmxcxmmjxnkszqnmnlwbwwqjjyhclstmcsxnjcxxt" "pcnfdtnnpglllzcjlspblpgjcdtnjjlyarscffjfqwdpgzdwmrzzcgodaxnssnyzrestyjwjyjdbcfxnmwttbqlwstszgybljpxg" "lbnclgpcbjftmxzljylzxcltpnclcgxtfzjshcrxsfysgdkntlbyjcyjllstgqcbxnhzxbxklylhzlqzlnzcqwgzlgzjncjgcmnz" "zgjdzxtzjxycyycxxjyyxjjxsssjstsstdppghtcsxwzdcsynptfbchfbblzjclzzdbxgcjlhpxnfzflsyltnwbmnjhszbmdnbcy" "sccldnycndqlyjjhmqllcsgljjsyfpyyccyltjantjjpwycmmgqyysxdxqmzhszxbftwwzqswqrfkjlzjqqyfbrxjhhfwjgzyqac" "myfrhcyybynwlpexcczsyyrlttdmqlrkmpbgmyyjprkznbbsqyxbhyzdjdnghpmfsgbwfzmfqmmbzmzdcgjlnnnxyqgmlrygqccy" "xzlwdkcjcggmcjjfyzzjhycfrrcmtznzxhkqgdjxccjeascrjthpljlrzdjrbcqhjdnrhylyqjsymhzydwcdfryhbbydtssccwbx" "glpzmlzjdqsscfjmmxjcxjytycghycjwynsxlfemwjnmkllswtxhyyyncmmcyjdqdjzglljwjnkhpzggflccsczmcbltbhbqjxqd" "jpdjztghglfjawbzyzjltstdhjhctcbchflqmpwdshyytqwcnntjtlnnmnndyyyxsqkxwyyflxxnzwcxypmaelyhgjwzzjbrxxaq" "jfllpfhhhytzzxsgqjmhspgdzqwbwpjhzjdyjcqwxkthxsqlzyymysdzgnqckknjlwpnsyscsyzlnmhqsyljxbcxtlhzqzpcycyk" "pppnsxfyzjjrcemhszmnxlxglrwgcstlrsxbygbzgnxcnlnjlclynymdxwtzpalcxpqjcjwtcyyjlblxbzlqmyljbghdslssdmxm" "bdczsxyhamlczcpjmcnhjyjnsykchskqmczqdllkablwjqsfmocdxjrrlyqchjmybyqlrhetfjzfrfksryxfjdwtsxxywsqjysly" "xwjhsdlxyyxhbhawhwjcxlmyljcsqlkydttxbzslfdxgxsjkhsxxybssxdpwncmrptqzczenygcxqfjxkjbdmljzmqqxnoxslyxx" "lylljdzptymhbfsttqqwlhsgynlzzalzxclhtwrrqhlstmypyxjjxmnsjnnbryxyjllyqyltwylqyfmlkljdnlltfzwkzhljmlhl" "jnljnnlqxylmbhhlnlzxqchxcfxxlhyhjjgbyzzkbxscqdjqdsndzsygzhhmgsxcsymxfepcqwwrbpyyjqryqcyjhqqzyhmwffhg" "zfrjfcdbxntqyzpcyhhjlfrzgpbxzdbbgrqstlgdgylcqmgchhmfywlzyxkjlypjhsywmqqggzmnzjnsqxlqsyjtcbehsxfszfxz" "wfllbcyyjdytdthwzsfjmqqyjlmqsxlldttkghybfpwdyysqqrnqwlgwdebzwcyygcnlkjxtmxmyjsxhybrwfymwfrxyymxysctz" "ztfykmldhqdlgyjnlcryjtlpsxxxywlsbrrjwxhqybhtydnhhxmmywytycnnmnssccdalwztcpqpyjllqzyjswjwzzmmglmxclmx" "nzmxmzsqtzppjqblpgxjzhfljjhycjsrxwcxsncdlxsyjdcqzxslqyclzxlzzxmxqrjmhrhzjbhmfljlmlclqnldxzlllfyprgjy" "nxcqqdcmqjzzxhnpnxzmemmsxykynlxsxtljxyhwdcwdzhqyybgybcyscfgfsjnzdrzzxqxrzrqjjymcanhrjtldbpyzbstjhxxz" "ypbdwfgzzrpymnnkxcqbyxnbnfyckrjjcmjegrzgyclnnzdnkknsjkcljspgyyclqqjybzssqlllkjftbgtylcccdblsppfylgyd" "tzjqjzgkntsfcxbdkdxxhybbfytyhbclnnytgdhryrnjsbtcsnyjqhklllzslydxxwbcjqsbxnpjzjzjdzfbxxbrmladhcsnclbj" "dstblprznswsbxbcllxxlzdnzsjpynyxxyftnnfbhjjjgbygjpmmmmsszljmtlyzjxswxtyledqpjmpgqzjgdjlqjwjqllsdgjgy" "gmscljjxdtygjqjjjcjzcjgdzdshqgzjggcjhqxsnjlzzbxhsgzxcxyljxyxyydfqqjhjfxdhctxjyrxysqtjxyefyyssyxjxncy" "zxfxcsxszxyyschshxzzzgzzzgfjdldylnpzgsjaztyqzpbxcbdztzczyxxyhhscjshcggqhjhgxhsctmzmehyxgebtclzkkwytj" "zrslekestdbcyhqqsayxcjxwwgsphjszsdncsjkqcxswxfctynydpccczjqtcwjqjzzzqzljzhlsbhpydxpsxshhezdxfptjqyzc" "xhyaxncfzyyhxgnqmywntzsjbnhhgymxmxqcnssbcqsjyxxtyyhybcqlmmszmjzzllcogxzaajzyhjmchhcxzsxsdznleyjjzjbh" "zwjzsqtzpsxzzdsqjjjlnyazphhyysrnqzthzhnyjyjhdzxzlswclybzyecwcycrylchzhzydzydyjdfrjjhtrsqtxyxjrjhojyn" "xelxsfsfjzghpzsxzszdzcqzbyyklsgsjhczshdgqgxyzgxchxzjwyqwgyhksseqzzndzfkwyssdclzstsymcdhjxxyweyxczayd" "mpxmdsxybsqmjmzjmtjqlpjyqzcgqhyjhhhqxhlhdldjqcfdwbsxfzzyyschtytyjbhecxhjkgqfxbhyzjfxhwhbdzfyzbchpnpg" "dydmsxhkhhmamlnbyjtmpxejmcthqbzyfcgtyhwphftgzzezsbzegpbmdskftycmhbllhgpzjxzjgzjyxzsbbqsczzlzscstpgxm" "zlsfdjsscbzgpdlfzfzszyzyzsygcxsnxxchczxtzzljfzgqsqqxcjqccccdjcdszzyqjccgxztdlgscxzsyjjqtcclqdqztqchq" "qyzynzzzpbkhdjfcjfztypqyqttynlmbdktjcpqzjdzfpjsbnjlgyjdxjdcqkzgqkxclbzjtcjdqbxdjjjstcxnxbxqmslyjcxnt" "jqwwcjjnjjlllhjcwqtbzqqczczpzzdzyddcyzdzccjgtjfzdprntctjdcxtqzdtjnplzbcllctdsxkjzqdmzlbznbtjdcxfczdb" "czjjltqqpldckztbbzjcqdcjwynllzlzccdwllxwzlxrxntqjczxkjlsgdnqtddglnlajjtnnynkqlldzntdnycygjwyxdxfrsqs" "tcdenqmrrqzhhqhdldazfkapbggpzrebzzykyqspeqjjglkqzzzjlysyhyzwfqznlzzlzhwcgkypqgnpgblplrrjyxcccgyhsfzf" "wbzywtgzxyljczwhncjzplfflgskhyjdeyxhlpllllcygxdrzelrhgklzzyhzlyqszzjzqljzflnbhgwlczcfjwspyxzlzlxgccp" "zbllcxbbbbnbbcbbcrnnzccnrbbnnldcgqyyqxygmqzwnzytyjhyfwtehznjywlccntzyjjcdedpwdztstnjhtymbjnyjzlxtsst" "phndjxxbyxqtzqddtjtdtgwscszqflshlnzbcjbhdlyzjyckwtydylbnydsdsycctyszyyebgexhqddwnygyclxtdcystqnygz" "ascsszzdzlcclzrqxyywljsbymxshzdembbllyyllytdqyshymrqnkfkbfxnnsbychxbwjyhtqbpbsbwdzylkgzskyghqzjxhxjx" "gnljkzlyycdxlfwfghljgjybxblybxqpqgntzplncybxdjyqydymrbeyjyyhkxxstmxrczzjwxyhybmcflyzhqyzfwxdbxbcwzms" "lpdmyckfmzklzcyqycclhxfzlydqzpzygyjyzmdxtzfnnyttqtzhgsfcdmlccytzxjcytjmkslpzhysnwllytpzctzccktxdhxxt" "qcyfksmqccyyazhtjplylzlyjbjxtfnyljyynrxcylmmnxjsmybcsysslzylljjgyldzdlqhfzzblfndsqkczfyhhgqmjdsxyctt" "xnqnjpyybfcjtyyfbnxejdgyqbjrcnfyyqpghyjsyzngrhtknlnndzntsmgklbygbpyszbydjzsstjztsxzbhbscsbzczptqfzlq" "flypybbjgszmnxdjmtsyskkbjtxhjcegbsmjyjzcstmljyxrczqscxxqpyzhmkyxxxjcljyrmyygadyskqlnadhrskqxzxztcggz" "dlmlwxybwsyctbhjhcfcwzsxwwtgzlxqshnyczjxemplsrcgltnzntlzjcyjgdtclglbllqpjmzpapxyzlaktkdwczzbncctdqqz" "qyjgmcdxltgcszlmlhbglkznnwzndxnhlnmkydlgxdtwcfrjerctzhydxykxhwfzcqshknmqqhzhhymjdjskhxzjzbzzxympajnm" "ctbxlsxlzynwrtsqgscbptbsgzwyhtlkssswhzzlyytnxjgmjrnsnnnnlskztxgxlsammlbwldqhylakqcqctmycfjbslxclzjcl" "xxknbnnzlhjphqplsxsckslnhpsfqcytxjjzljldtzjjzdlydjntptnndskjfsljhylzqqzlbthydgdjfdbyadxdzhzjnthqbykn" "xjjqczmlljzkspldsclbblnnlelxjlbjycxjxgcnlcqplzlznjtsljgyzdzpltqcssfdmnycxgbtjdcznbgbqyqjwgkfhtnbyqzq" "gbkpbbyzmtjdytblsqmbsxtbnpdxklemyycjynzdtldykzzxtdxhqshygmzsjycctayrzlpwltlkxslzcggexclfxlkjrtlqjaqz" "ncmbqdkkcxglczjzxjhptdjjmzqykqsecqzdshhadmlzfmmzbgntjnnlhbyjbrbtmlbyjdzxlcjlpldlpcqdhlhzlycblcxccjad" "qlmzmmsshmybhbnkkbhrsxxjmxmdznnpklbbrhgghfchgmnklltsyyycqlcskymyehywxnxqywbawykqldnntndkhqcgdqktgpkx" "hcpdhtwnmssyhbwcrwxhjmkmzngwtmlkfghkjyldyycxwhyyclqhkqhtdqkhffldxqwytyydesbpkyrzpjfyyzjceqdzzdlattpb" "fjllcxdlmjsdxegwgsjqxcfbssszpdyzcxznyxppzydlyjccpltxlnxyzyrscyyytylwwndsahjsygyhgywwaxtjzdaxysrltdps" "syxfnejdxyzhlxlllzhzsjnyqyqyxyjghzgjcyjchzlycdshhsgczyjscllnxzjjyyxnfsmwfpyllyllabmddhwzxjmcxztzpmlq" "chsfwzynctlndywlslxhymmylmbwwkyxyaddxylldjpybpwnxjmmmllhafdllaflbnhhbqqjqzjcqjjdjtffkmmmpythygdrjrdd" "wrqjxnbysrmzdbyytbjhpymyjtjxaahggdqtmystqxkbtzbkjlxrbyqqhxmjjbdjntgtbxpgbktlgqxjjjcdhxqdwjlwrfmjgwqh" "cnrxswgbtgygbwhswdwrfhwytjjxxxjyzyslphyypyyxhydqpxshxyxgskqhywbdddpplcjlhqeewjgsyykdpplfjthkjltcyjhh" "jttpltzzcdlyhqkcjqysteeyhkyzyxxyysddjkllpymqyhqgxqhzrhbxpllnqydqhxsxxwgdqbshyllpjjjthyjkyphthyyktyez" "yenmdshlzrpqfbnfxzbsftlgxsjbswyysksflxlpplbbblnsfbfyzbsjssylpbbffffsscjdstjsxtryjcyffsyzyzbjtlctsbsd" "hrtjjbytcxyyeylycbnebjdsysyhgsjzbxbytfzwgenhhhthjhhxfwgcstbgxklstyymtmbyxjskzscdyjrcythxzfhmymcxlzns" "djtxtxrycfyjsbsdyerxhljxbbdeynjghxgckgscymblxjmsznskgxfbnbbthfjyafxwxfbxmyfhdttcxzzpxrsywzdlybbktyqw" "qjbzypzjznjpzjlztfysbttslmptzrtdxqsjehbnylndxljsqmlhtxtjecxalzzspktlzkqqyfsyjywpcpqfhjhytqxzkrsgtksq" "czlptxcdyyzsslzslxlzmacpcqbzyxhbsxlzdltztjtylzjyytbzypltxjsjxhlbmytxcqrblzssfjzztnjytxmyjhlhpblcyxqj" "qqkzzscpzkswalqsplczzjsxgwwwygyatjbbctdkhqhkgtgpbkqyslbxbbckbmllndzstbklggqkqlzbkktfxrmdkbftpzfrtppm" "ferqnxgjpzsstlbztpszqzsjdhljqlzbpmsmmsxlqqnhknblrddnhxdkddjcyyljfqgzlgsygmjqjkhbpmxyxlytqwlwjcpbmjxc" "yzydrjbhtdjyeqshtmgsfyplwhlzffnynnhxqhpltbqpfbjwjdbygpnxtbfzjgnnntjshxeawtzylltyqbwjpgxghnnkndjtmszs" "qynzggnwqtfhclssgmnnnnynzqqxncjdqgzdlfnykljcjllzlmzznnnnsshthxjlzjbbhqjwwycrdhlyqqjbeyfsjhthnrnwjhwp" "slmssgzttygrqqwrnlalhmjtqjsmxqbjjzjqzyzkxbjqxbjxshzssfglxmxnxfghkzszggslcnnarjxhnlllmzxelglxydjytlfb" "kbpnlyzfbbhptgjkwetzhkjjxzxxglljlstgshjjyqlqzfkcgnndjsszfdbctwwseqfhqjbsaqtgypjlbxbmmywxgslzhglsgnyf" "ljbyfdjfngsfmbyzhqffwjsyfyjjphzbyyzffwotjnlmftwlbzgyzqxcdjygzyyryzynyzwegazyhjjlzrthlrmgrjxzclnnnljj" "yhtbwjybxxbxjjtjteekhwslnnlbsfazpqqbdlqjjtyyqlyzkdksqjnejzldqcgjqnnjsncmrfqthtejmfctyhypymhydmjncfgy" "yxwshctxrljgjzhzcyyyjltkttntmjlzclzzayyoczlrlbszywjytsjyhbyshfjlykjxxtmzyyltxxypslqyjzyzyypnhmymdyyl" "blhlsyygqllnjjymsoycbzgdlyxylcqyxtszegxhzglhwbljheyxtwqmakbpqcgyshhegqcmwyywljyjhyyzlljjylhzyhmgsljl" "jxcjjyclycjbcpzjzjmmwlcjlnqljjjlxyjmlszljqlycmmgcfmmfpqqmfxlqmcffqmmmmhnznfhhjgtthxkhslnchhyqzxtmmqd" "cydyxyqmyqylddcyaytazdcymdydlzfffmmycqcwzzmabtbyctdmndzggdftypcgqyttssffwbdttqssystwnjhjytsxxylbyyhh" "whxgzxwznnqzjzjjqjccchykxbzszcnjtllcqxynjnckycynccqnxyewyczdcjycchyjlbtzyycqwlpgpyllgktltlgkgqbgychj" "xy"; char pinyinFirstLetter(unsigned short hanzi) { int index = hanzi - HANZI_START; if (index >= 0 && index <= HANZI_COUNT) { return firstLetterArray[index]; } else { return '#'; } }
the_stack_data/247017267.c
#include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <complex.h> #ifdef complex #undef complex #endif #ifdef I #undef I #endif #if defined(_WIN64) typedef long long BLASLONG; typedef unsigned long long BLASULONG; #else typedef long BLASLONG; typedef unsigned long BLASULONG; #endif #ifdef LAPACK_ILP64 typedef BLASLONG blasint; #if defined(_WIN64) #define blasabs(x) llabs(x) #else #define blasabs(x) labs(x) #endif #else typedef int blasint; #define blasabs(x) abs(x) #endif typedef blasint integer; typedef unsigned int uinteger; typedef char *address; typedef short int shortint; typedef float real; typedef double doublereal; typedef struct { real r, i; } complex; typedef struct { doublereal r, i; } doublecomplex; #ifdef _MSC_VER static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;} static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;} static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;} static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;} #else static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;} static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;} static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;} static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;} #endif #define pCf(z) (*_pCf(z)) #define pCd(z) (*_pCd(z)) typedef int logical; typedef short int shortlogical; typedef char logical1; typedef char integer1; #define TRUE_ (1) #define FALSE_ (0) /* Extern is for use with -E */ #ifndef Extern #define Extern extern #endif /* I/O stuff */ typedef int flag; typedef int ftnlen; typedef int ftnint; /*external read, write*/ typedef struct { flag cierr; ftnint ciunit; flag ciend; char *cifmt; ftnint cirec; } cilist; /*internal read, write*/ typedef struct { flag icierr; char *iciunit; flag iciend; char *icifmt; ftnint icirlen; ftnint icirnum; } icilist; /*open*/ typedef struct { flag oerr; ftnint ounit; char *ofnm; ftnlen ofnmlen; char *osta; char *oacc; char *ofm; ftnint orl; char *oblnk; } olist; /*close*/ typedef struct { flag cerr; ftnint cunit; char *csta; } cllist; /*rewind, backspace, endfile*/ typedef struct { flag aerr; ftnint aunit; } alist; /* inquire */ typedef struct { flag inerr; ftnint inunit; char *infile; ftnlen infilen; ftnint *inex; /*parameters in standard's order*/ ftnint *inopen; ftnint *innum; ftnint *innamed; char *inname; ftnlen innamlen; char *inacc; ftnlen inacclen; char *inseq; ftnlen inseqlen; char *indir; ftnlen indirlen; char *infmt; ftnlen infmtlen; char *inform; ftnint informlen; char *inunf; ftnlen inunflen; ftnint *inrecl; ftnint *innrec; char *inblank; ftnlen inblanklen; } inlist; #define VOID void union Multitype { /* for multiple entry points */ integer1 g; shortint h; integer i; /* longint j; */ real r; doublereal d; complex c; doublecomplex z; }; typedef union Multitype Multitype; struct Vardesc { /* for Namelist */ char *name; char *addr; ftnlen *dims; int type; }; typedef struct Vardesc Vardesc; struct Namelist { char *name; Vardesc **vars; int nvars; }; typedef struct Namelist Namelist; #define abs(x) ((x) >= 0 ? (x) : -(x)) #define dabs(x) (fabs(x)) #define f2cmin(a,b) ((a) <= (b) ? (a) : (b)) #define f2cmax(a,b) ((a) >= (b) ? (a) : (b)) #define dmin(a,b) (f2cmin(a,b)) #define dmax(a,b) (f2cmax(a,b)) #define bit_test(a,b) ((a) >> (b) & 1) #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b))) #define bit_set(a,b) ((a) | ((uinteger)1 << (b))) #define abort_() { sig_die("Fortran abort routine called", 1); } #define c_abs(z) (cabsf(Cf(z))) #define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); } #ifdef _MSC_VER #define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);} #define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/df(b)._Val[1]);} #else #define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);} #define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);} #endif #define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));} #define c_log(R, Z) {pCf(R) = clogf(Cf(Z));} #define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));} //#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));} #define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));} #define d_abs(x) (fabs(*(x))) #define d_acos(x) (acos(*(x))) #define d_asin(x) (asin(*(x))) #define d_atan(x) (atan(*(x))) #define d_atn2(x, y) (atan2(*(x),*(y))) #define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); } #define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); } #define d_cos(x) (cos(*(x))) #define d_cosh(x) (cosh(*(x))) #define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 ) #define d_exp(x) (exp(*(x))) #define d_imag(z) (cimag(Cd(z))) #define r_imag(z) (cimagf(Cf(z))) #define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x))) #define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) ) #define d_log(x) (log(*(x))) #define d_mod(x, y) (fmod(*(x), *(y))) #define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x))) #define d_nint(x) u_nint(*(x)) #define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a))) #define d_sign(a,b) u_sign(*(a),*(b)) #define r_sign(a,b) u_sign(*(a),*(b)) #define d_sin(x) (sin(*(x))) #define d_sinh(x) (sinh(*(x))) #define d_sqrt(x) (sqrt(*(x))) #define d_tan(x) (tan(*(x))) #define d_tanh(x) (tanh(*(x))) #define i_abs(x) abs(*(x)) #define i_dnnt(x) ((integer)u_nint(*(x))) #define i_len(s, n) (n) #define i_nint(x) ((integer)u_nint(*(x))) #define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b))) #define pow_dd(ap, bp) ( pow(*(ap), *(bp))) #define pow_si(B,E) spow_ui(*(B),*(E)) #define pow_ri(B,E) spow_ui(*(B),*(E)) #define pow_di(B,E) dpow_ui(*(B),*(E)) #define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));} #define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));} #define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));} #define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; } #define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d)))) #define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; } #define sig_die(s, kill) { exit(1); } #define s_stop(s, n) {exit(0);} static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n"; #define z_abs(z) (cabs(Cd(z))) #define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));} #define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));} #define myexit_() break; #define mycycle() continue; #define myceiling(w) {ceil(w)} #define myhuge(w) {HUGE_VAL} //#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);} #define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)} /* procedure parameter types for -A and -C++ */ #define F2C_proc_par_types 1 #ifdef __cplusplus typedef logical (*L_fp)(...); #else typedef logical (*L_fp)(); #endif static float spow_ui(float x, integer n) { float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static double dpow_ui(double x, integer n) { double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #ifdef _MSC_VER static _Fcomplex cpow_ui(complex x, integer n) { complex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i; for(u = n; ; ) { if(u & 01) pow.r *= x.r, pow.i *= x.i; if(u >>= 1) x.r *= x.r, x.i *= x.i; else break; } } _Fcomplex p={pow.r, pow.i}; return p; } #else static _Complex float cpow_ui(_Complex float x, integer n) { _Complex float pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif #ifdef _MSC_VER static _Dcomplex zpow_ui(_Dcomplex x, integer n) { _Dcomplex pow={1.0,0.0}; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1]; for(u = n; ; ) { if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1]; if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1]; else break; } } _Dcomplex p = {pow._Val[0], pow._Val[1]}; return p; } #else static _Complex double zpow_ui(_Complex double x, integer n) { _Complex double pow=1.0; unsigned long int u; if(n != 0) { if(n < 0) n = -n, x = 1/x; for(u = n; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } #endif static integer pow_ii(integer x, integer n) { integer pow; unsigned long int u; if (n <= 0) { if (n == 0 || x == 1) pow = 1; else if (x != -1) pow = x == 0 ? 1/x : 0; else n = -n; } if ((n > 0) || !(n == 0 || x == 1 || x != -1)) { u = n; for(pow = 1; ; ) { if(u & 01) pow *= x; if(u >>= 1) x *= x; else break; } } return pow; } static integer dmaxloc_(double *w, integer s, integer e, integer *n) { double m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static integer smaxloc_(float *w, integer s, integer e, integer *n) { float m; integer i, mi; for(m=w[s-1], mi=s, i=s+1; i<=e; i++) if (w[i-1]>m) mi=i ,m=w[i-1]; return mi-s+1; } static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i])) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i])) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Fcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0]; zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0]; zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1]; } } pCf(z) = zdotc; } #else _Complex float zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i]) * Cf(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]); } } pCf(z) = zdotc; } #endif static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) { integer n = *n_, incx = *incx_, incy = *incy_, i; #ifdef _MSC_VER _Dcomplex zdotc = {0.0, 0.0}; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0]; zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1]; } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0]; zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1]; } } pCd(z) = zdotc; } #else _Complex double zdotc = 0.0; if (incx == 1 && incy == 1) { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i]) * Cd(&y[i]); } } else { for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */ zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]); } } pCd(z) = zdotc; } #endif /* -- translated by f2c (version 20000121). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ /* Table of constant values */ static complex c_b1 = {1.f,0.f}; static complex c_b3 = {0.f,0.f}; static complex c_b5 = {20.f,0.f}; /* > \brief \b CLATM5 */ /* =========== DOCUMENTATION =========== */ /* Online html documentation available at */ /* http://www.netlib.org/lapack/explore-html/ */ /* Definition: */ /* =========== */ /* SUBROUTINE CLATM5( PRTYPE, M, N, A, LDA, B, LDB, C, LDC, D, LDD, */ /* E, LDE, F, LDF, R, LDR, L, LDL, ALPHA, QBLCKA, */ /* QBLCKB ) */ /* INTEGER LDA, LDB, LDC, LDD, LDE, LDF, LDL, LDR, M, N, */ /* $ PRTYPE, QBLCKA, QBLCKB */ /* REAL ALPHA */ /* COMPLEX A( LDA, * ), B( LDB, * ), C( LDC, * ), */ /* $ D( LDD, * ), E( LDE, * ), F( LDF, * ), */ /* $ L( LDL, * ), R( LDR, * ) */ /* > \par Purpose: */ /* ============= */ /* > */ /* > \verbatim */ /* > */ /* > CLATM5 generates matrices involved in the Generalized Sylvester */ /* > equation: */ /* > */ /* > A * R - L * B = C */ /* > D * R - L * E = F */ /* > */ /* > They also satisfy (the diagonalization condition) */ /* > */ /* > [ I -L ] ( [ A -C ], [ D -F ] ) [ I R ] = ( [ A ], [ D ] ) */ /* > [ I ] ( [ B ] [ E ] ) [ I ] ( [ B ] [ E ] ) */ /* > */ /* > \endverbatim */ /* Arguments: */ /* ========== */ /* > \param[in] PRTYPE */ /* > \verbatim */ /* > PRTYPE is INTEGER */ /* > "Points" to a certain type of the matrices to generate */ /* > (see further details). */ /* > \endverbatim */ /* > */ /* > \param[in] M */ /* > \verbatim */ /* > M is INTEGER */ /* > Specifies the order of A and D and the number of rows in */ /* > C, F, R and L. */ /* > \endverbatim */ /* > */ /* > \param[in] N */ /* > \verbatim */ /* > N is INTEGER */ /* > Specifies the order of B and E and the number of columns in */ /* > C, F, R and L. */ /* > \endverbatim */ /* > */ /* > \param[out] A */ /* > \verbatim */ /* > A is COMPLEX array, dimension (LDA, M). */ /* > On exit A M-by-M is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDA */ /* > \verbatim */ /* > LDA is INTEGER */ /* > The leading dimension of A. */ /* > \endverbatim */ /* > */ /* > \param[out] B */ /* > \verbatim */ /* > B is COMPLEX array, dimension (LDB, N). */ /* > On exit B N-by-N is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDB */ /* > \verbatim */ /* > LDB is INTEGER */ /* > The leading dimension of B. */ /* > \endverbatim */ /* > */ /* > \param[out] C */ /* > \verbatim */ /* > C is COMPLEX array, dimension (LDC, N). */ /* > On exit C M-by-N is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDC */ /* > \verbatim */ /* > LDC is INTEGER */ /* > The leading dimension of C. */ /* > \endverbatim */ /* > */ /* > \param[out] D */ /* > \verbatim */ /* > D is COMPLEX array, dimension (LDD, M). */ /* > On exit D M-by-M is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDD */ /* > \verbatim */ /* > LDD is INTEGER */ /* > The leading dimension of D. */ /* > \endverbatim */ /* > */ /* > \param[out] E */ /* > \verbatim */ /* > E is COMPLEX array, dimension (LDE, N). */ /* > On exit E N-by-N is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDE */ /* > \verbatim */ /* > LDE is INTEGER */ /* > The leading dimension of E. */ /* > \endverbatim */ /* > */ /* > \param[out] F */ /* > \verbatim */ /* > F is COMPLEX array, dimension (LDF, N). */ /* > On exit F M-by-N is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDF */ /* > \verbatim */ /* > LDF is INTEGER */ /* > The leading dimension of F. */ /* > \endverbatim */ /* > */ /* > \param[out] R */ /* > \verbatim */ /* > R is COMPLEX array, dimension (LDR, N). */ /* > On exit R M-by-N is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDR */ /* > \verbatim */ /* > LDR is INTEGER */ /* > The leading dimension of R. */ /* > \endverbatim */ /* > */ /* > \param[out] L */ /* > \verbatim */ /* > L is COMPLEX array, dimension (LDL, N). */ /* > On exit L M-by-N is initialized according to PRTYPE. */ /* > \endverbatim */ /* > */ /* > \param[in] LDL */ /* > \verbatim */ /* > LDL is INTEGER */ /* > The leading dimension of L. */ /* > \endverbatim */ /* > */ /* > \param[in] ALPHA */ /* > \verbatim */ /* > ALPHA is REAL */ /* > Parameter used in generating PRTYPE = 1 and 5 matrices. */ /* > \endverbatim */ /* > */ /* > \param[in] QBLCKA */ /* > \verbatim */ /* > QBLCKA is INTEGER */ /* > When PRTYPE = 3, specifies the distance between 2-by-2 */ /* > blocks on the diagonal in A. Otherwise, QBLCKA is not */ /* > referenced. QBLCKA > 1. */ /* > \endverbatim */ /* > */ /* > \param[in] QBLCKB */ /* > \verbatim */ /* > QBLCKB is INTEGER */ /* > When PRTYPE = 3, specifies the distance between 2-by-2 */ /* > blocks on the diagonal in B. Otherwise, QBLCKB is not */ /* > referenced. QBLCKB > 1. */ /* > \endverbatim */ /* Authors: */ /* ======== */ /* > \author Univ. of Tennessee */ /* > \author Univ. of California Berkeley */ /* > \author Univ. of Colorado Denver */ /* > \author NAG Ltd. */ /* > \date June 2016 */ /* > \ingroup complex_matgen */ /* > \par Further Details: */ /* ===================== */ /* > */ /* > \verbatim */ /* > */ /* > PRTYPE = 1: A and B are Jordan blocks, D and E are identity matrices */ /* > */ /* > A : if (i == j) then A(i, j) = 1.0 */ /* > if (j == i + 1) then A(i, j) = -1.0 */ /* > else A(i, j) = 0.0, i, j = 1...M */ /* > */ /* > B : if (i == j) then B(i, j) = 1.0 - ALPHA */ /* > if (j == i + 1) then B(i, j) = 1.0 */ /* > else B(i, j) = 0.0, i, j = 1...N */ /* > */ /* > D : if (i == j) then D(i, j) = 1.0 */ /* > else D(i, j) = 0.0, i, j = 1...M */ /* > */ /* > E : if (i == j) then E(i, j) = 1.0 */ /* > else E(i, j) = 0.0, i, j = 1...N */ /* > */ /* > L = R are chosen from [-10...10], */ /* > which specifies the right hand sides (C, F). */ /* > */ /* > PRTYPE = 2 or 3: Triangular and/or quasi- triangular. */ /* > */ /* > A : if (i <= j) then A(i, j) = [-1...1] */ /* > else A(i, j) = 0.0, i, j = 1...M */ /* > */ /* > if (PRTYPE = 3) then */ /* > A(k + 1, k + 1) = A(k, k) */ /* > A(k + 1, k) = [-1...1] */ /* > sign(A(k, k + 1) = -(sin(A(k + 1, k)) */ /* > k = 1, M - 1, QBLCKA */ /* > */ /* > B : if (i <= j) then B(i, j) = [-1...1] */ /* > else B(i, j) = 0.0, i, j = 1...N */ /* > */ /* > if (PRTYPE = 3) then */ /* > B(k + 1, k + 1) = B(k, k) */ /* > B(k + 1, k) = [-1...1] */ /* > sign(B(k, k + 1) = -(sign(B(k + 1, k)) */ /* > k = 1, N - 1, QBLCKB */ /* > */ /* > D : if (i <= j) then D(i, j) = [-1...1]. */ /* > else D(i, j) = 0.0, i, j = 1...M */ /* > */ /* > */ /* > E : if (i <= j) then D(i, j) = [-1...1] */ /* > else E(i, j) = 0.0, i, j = 1...N */ /* > */ /* > L, R are chosen from [-10...10], */ /* > which specifies the right hand sides (C, F). */ /* > */ /* > PRTYPE = 4 Full */ /* > A(i, j) = [-10...10] */ /* > D(i, j) = [-1...1] i,j = 1...M */ /* > B(i, j) = [-10...10] */ /* > E(i, j) = [-1...1] i,j = 1...N */ /* > R(i, j) = [-10...10] */ /* > L(i, j) = [-1...1] i = 1..M ,j = 1...N */ /* > */ /* > L, R specifies the right hand sides (C, F). */ /* > */ /* > PRTYPE = 5 special case common and/or close eigs. */ /* > \endverbatim */ /* > */ /* ===================================================================== */ /* Subroutine */ int clatm5_(integer *prtype, integer *m, integer *n, complex *a, integer *lda, complex *b, integer *ldb, complex *c__, integer * ldc, complex *d__, integer *ldd, complex *e, integer *lde, complex *f, integer *ldf, complex *r__, integer *ldr, complex *l, integer *ldl, real *alpha, integer *qblcka, integer *qblckb) { /* System generated locals */ integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1, d_offset, e_dim1, e_offset, f_dim1, f_offset, l_dim1, l_offset, r_dim1, r_offset, i__1, i__2, i__3, i__4; doublereal d__1; complex q__1, q__2, q__3, q__4, q__5; /* Local variables */ integer i__, j, k; extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, integer *, complex *, complex *, integer *, complex *, integer *, complex *, complex *, integer *); complex imeps, reeps; /* -- LAPACK computational routine (version 3.7.0) -- */ /* -- LAPACK is a software package provided by Univ. of Tennessee, -- */ /* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */ /* June 2016 */ /* ===================================================================== */ /* Parameter adjustments */ a_dim1 = *lda; a_offset = 1 + a_dim1 * 1; a -= a_offset; b_dim1 = *ldb; b_offset = 1 + b_dim1 * 1; b -= b_offset; c_dim1 = *ldc; c_offset = 1 + c_dim1 * 1; c__ -= c_offset; d_dim1 = *ldd; d_offset = 1 + d_dim1 * 1; d__ -= d_offset; e_dim1 = *lde; e_offset = 1 + e_dim1 * 1; e -= e_offset; f_dim1 = *ldf; f_offset = 1 + f_dim1 * 1; f -= f_offset; r_dim1 = *ldr; r_offset = 1 + r_dim1 * 1; r__ -= r_offset; l_dim1 = *ldl; l_offset = 1 + l_dim1 * 1; l -= l_offset; /* Function Body */ if (*prtype == 1) { i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *m; for (j = 1; j <= i__2; ++j) { if (i__ == j) { i__3 = i__ + j * a_dim1; a[i__3].r = 1.f, a[i__3].i = 0.f; i__3 = i__ + j * d_dim1; d__[i__3].r = 1.f, d__[i__3].i = 0.f; } else if (i__ == j - 1) { i__3 = i__ + j * a_dim1; q__1.r = -1.f, q__1.i = 0.f; a[i__3].r = q__1.r, a[i__3].i = q__1.i; i__3 = i__ + j * d_dim1; d__[i__3].r = 0.f, d__[i__3].i = 0.f; } else { i__3 = i__ + j * a_dim1; a[i__3].r = 0.f, a[i__3].i = 0.f; i__3 = i__ + j * d_dim1; d__[i__3].r = 0.f, d__[i__3].i = 0.f; } /* L10: */ } /* L20: */ } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { if (i__ == j) { i__3 = i__ + j * b_dim1; q__1.r = 1.f - *alpha, q__1.i = 0.f; b[i__3].r = q__1.r, b[i__3].i = q__1.i; i__3 = i__ + j * e_dim1; e[i__3].r = 1.f, e[i__3].i = 0.f; } else if (i__ == j - 1) { i__3 = i__ + j * b_dim1; b[i__3].r = 1.f, b[i__3].i = 0.f; i__3 = i__ + j * e_dim1; e[i__3].r = 0.f, e[i__3].i = 0.f; } else { i__3 = i__ + j * b_dim1; b[i__3].r = 0.f, b[i__3].i = 0.f; i__3 = i__ + j * e_dim1; e[i__3].r = 0.f, e[i__3].i = 0.f; } /* L30: */ } /* L40: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { i__3 = i__ + j * r_dim1; i__4 = i__ / j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 20.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 20.f; r__[i__3].r = q__1.r, r__[i__3].i = q__1.i; i__3 = i__ + j * l_dim1; i__4 = i__ + j * r_dim1; l[i__3].r = r__[i__4].r, l[i__3].i = r__[i__4].i; /* L50: */ } /* L60: */ } } else if (*prtype == 2 || *prtype == 3) { i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *m; for (j = 1; j <= i__2; ++j) { if (i__ <= j) { i__3 = i__ + j * a_dim1; q__4.r = (real) i__, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 2.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 2.f; a[i__3].r = q__1.r, a[i__3].i = q__1.i; i__3 = i__ + j * d_dim1; i__4 = i__ * j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 2.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 2.f; d__[i__3].r = q__1.r, d__[i__3].i = q__1.i; } else { i__3 = i__ + j * a_dim1; a[i__3].r = 0.f, a[i__3].i = 0.f; i__3 = i__ + j * d_dim1; d__[i__3].r = 0.f, d__[i__3].i = 0.f; } /* L70: */ } /* L80: */ } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { if (i__ <= j) { i__3 = i__ + j * b_dim1; i__4 = i__ + j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 2.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 2.f; b[i__3].r = q__1.r, b[i__3].i = q__1.i; i__3 = i__ + j * e_dim1; q__4.r = (real) j, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 2.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 2.f; e[i__3].r = q__1.r, e[i__3].i = q__1.i; } else { i__3 = i__ + j * b_dim1; b[i__3].r = 0.f, b[i__3].i = 0.f; i__3 = i__ + j * e_dim1; e[i__3].r = 0.f, e[i__3].i = 0.f; } /* L90: */ } /* L100: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { i__3 = i__ + j * r_dim1; i__4 = i__ * j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 20.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 20.f; r__[i__3].r = q__1.r, r__[i__3].i = q__1.i; i__3 = i__ + j * l_dim1; i__4 = i__ + j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 20.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 20.f; l[i__3].r = q__1.r, l[i__3].i = q__1.i; /* L110: */ } /* L120: */ } if (*prtype == 3) { if (*qblcka <= 1) { *qblcka = 2; } i__1 = *m - 1; i__2 = *qblcka; for (k = 1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) { i__3 = k + 1 + (k + 1) * a_dim1; i__4 = k + k * a_dim1; a[i__3].r = a[i__4].r, a[i__3].i = a[i__4].i; i__3 = k + 1 + k * a_dim1; c_sin(&q__2, &a[k + (k + 1) * a_dim1]); q__1.r = -q__2.r, q__1.i = -q__2.i; a[i__3].r = q__1.r, a[i__3].i = q__1.i; /* L130: */ } if (*qblckb <= 1) { *qblckb = 2; } i__2 = *n - 1; i__1 = *qblckb; for (k = 1; i__1 < 0 ? k >= i__2 : k <= i__2; k += i__1) { i__3 = k + 1 + (k + 1) * b_dim1; i__4 = k + k * b_dim1; b[i__3].r = b[i__4].r, b[i__3].i = b[i__4].i; i__3 = k + 1 + k * b_dim1; c_sin(&q__2, &b[k + (k + 1) * b_dim1]); q__1.r = -q__2.r, q__1.i = -q__2.i; b[i__3].r = q__1.r, b[i__3].i = q__1.i; /* L140: */ } } } else if (*prtype == 4) { i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *m; for (j = 1; j <= i__2; ++j) { i__3 = i__ + j * a_dim1; i__4 = i__ * j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 20.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 20.f; a[i__3].r = q__1.r, a[i__3].i = q__1.i; i__3 = i__ + j * d_dim1; i__4 = i__ + j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 2.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 2.f; d__[i__3].r = q__1.r, d__[i__3].i = q__1.i; /* L150: */ } /* L160: */ } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { i__3 = i__ + j * b_dim1; i__4 = i__ + j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 20.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 20.f; b[i__3].r = q__1.r, b[i__3].i = q__1.i; i__3 = i__ + j * e_dim1; i__4 = i__ * j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 2.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 2.f; e[i__3].r = q__1.r, e[i__3].i = q__1.i; /* L170: */ } /* L180: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { i__3 = i__ + j * r_dim1; i__4 = j / i__; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 20.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 20.f; r__[i__3].r = q__1.r, r__[i__3].i = q__1.i; i__3 = i__ + j * l_dim1; i__4 = i__ * j; q__4.r = (real) i__4, q__4.i = 0.f; c_sin(&q__3, &q__4); q__2.r = .5f - q__3.r, q__2.i = 0.f - q__3.i; q__1.r = q__2.r * 2.f - q__2.i * 0.f, q__1.i = q__2.r * 0.f + q__2.i * 2.f; l[i__3].r = q__1.r, l[i__3].i = q__1.i; /* L190: */ } /* L200: */ } } else if (*prtype >= 5) { q__3.r = 1.f, q__3.i = 0.f; q__2.r = q__3.r * 20.f - q__3.i * 0.f, q__2.i = q__3.r * 0.f + q__3.i * 20.f; q__1.r = q__2.r / *alpha, q__1.i = q__2.i / *alpha; reeps.r = q__1.r, reeps.i = q__1.i; q__2.r = -1.5f, q__2.i = 0.f; q__1.r = q__2.r / *alpha, q__1.i = q__2.i / *alpha; imeps.r = q__1.r, imeps.i = q__1.i; i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = *n; for (j = 1; j <= i__2; ++j) { i__3 = i__ + j * r_dim1; i__4 = i__ * j; q__5.r = (real) i__4, q__5.i = 0.f; c_sin(&q__4, &q__5); q__3.r = .5f - q__4.r, q__3.i = 0.f - q__4.i; q__2.r = *alpha * q__3.r, q__2.i = *alpha * q__3.i; c_div(&q__1, &q__2, &c_b5); r__[i__3].r = q__1.r, r__[i__3].i = q__1.i; i__3 = i__ + j * l_dim1; i__4 = i__ + j; q__5.r = (real) i__4, q__5.i = 0.f; c_sin(&q__4, &q__5); q__3.r = .5f - q__4.r, q__3.i = 0.f - q__4.i; q__2.r = *alpha * q__3.r, q__2.i = *alpha * q__3.i; c_div(&q__1, &q__2, &c_b5); l[i__3].r = q__1.r, l[i__3].i = q__1.i; /* L210: */ } /* L220: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = i__ + i__ * d_dim1; d__[i__2].r = 1.f, d__[i__2].i = 0.f; /* L230: */ } i__1 = *m; for (i__ = 1; i__ <= i__1; ++i__) { if (i__ <= 4) { i__2 = i__ + i__ * a_dim1; a[i__2].r = 1.f, a[i__2].i = 0.f; if (i__ > 2) { i__2 = i__ + i__ * a_dim1; q__1.r = reeps.r + 1.f, q__1.i = reeps.i + 0.f; a[i__2].r = q__1.r, a[i__2].i = q__1.i; } if (i__ % 2 != 0 && i__ < *m) { i__2 = i__ + (i__ + 1) * a_dim1; a[i__2].r = imeps.r, a[i__2].i = imeps.i; } else if (i__ > 1) { i__2 = i__ + (i__ - 1) * a_dim1; q__1.r = -imeps.r, q__1.i = -imeps.i; a[i__2].r = q__1.r, a[i__2].i = q__1.i; } } else if (i__ <= 8) { if (i__ <= 6) { i__2 = i__ + i__ * a_dim1; a[i__2].r = reeps.r, a[i__2].i = reeps.i; } else { i__2 = i__ + i__ * a_dim1; q__1.r = -reeps.r, q__1.i = -reeps.i; a[i__2].r = q__1.r, a[i__2].i = q__1.i; } if (i__ % 2 != 0 && i__ < *m) { i__2 = i__ + (i__ + 1) * a_dim1; a[i__2].r = 1.f, a[i__2].i = 0.f; } else if (i__ > 1) { i__2 = i__ + (i__ - 1) * a_dim1; q__1.r = -1.f, q__1.i = 0.f; a[i__2].r = q__1.r, a[i__2].i = q__1.i; } } else { i__2 = i__ + i__ * a_dim1; a[i__2].r = 1.f, a[i__2].i = 0.f; if (i__ % 2 != 0 && i__ < *m) { i__2 = i__ + (i__ + 1) * a_dim1; d__1 = 2.; q__1.r = d__1 * imeps.r, q__1.i = d__1 * imeps.i; a[i__2].r = q__1.r, a[i__2].i = q__1.i; } else if (i__ > 1) { i__2 = i__ + (i__ - 1) * a_dim1; q__2.r = -imeps.r, q__2.i = -imeps.i; d__1 = 2.; q__1.r = d__1 * q__2.r, q__1.i = d__1 * q__2.i; a[i__2].r = q__1.r, a[i__2].i = q__1.i; } } /* L240: */ } i__1 = *n; for (i__ = 1; i__ <= i__1; ++i__) { i__2 = i__ + i__ * e_dim1; e[i__2].r = 1.f, e[i__2].i = 0.f; if (i__ <= 4) { i__2 = i__ + i__ * b_dim1; q__1.r = -1.f, q__1.i = 0.f; b[i__2].r = q__1.r, b[i__2].i = q__1.i; if (i__ > 2) { i__2 = i__ + i__ * b_dim1; q__1.r = 1.f - reeps.r, q__1.i = 0.f - reeps.i; b[i__2].r = q__1.r, b[i__2].i = q__1.i; } if (i__ % 2 != 0 && i__ < *n) { i__2 = i__ + (i__ + 1) * b_dim1; b[i__2].r = imeps.r, b[i__2].i = imeps.i; } else if (i__ > 1) { i__2 = i__ + (i__ - 1) * b_dim1; q__1.r = -imeps.r, q__1.i = -imeps.i; b[i__2].r = q__1.r, b[i__2].i = q__1.i; } } else if (i__ <= 8) { if (i__ <= 6) { i__2 = i__ + i__ * b_dim1; b[i__2].r = reeps.r, b[i__2].i = reeps.i; } else { i__2 = i__ + i__ * b_dim1; q__1.r = -reeps.r, q__1.i = -reeps.i; b[i__2].r = q__1.r, b[i__2].i = q__1.i; } if (i__ % 2 != 0 && i__ < *n) { i__2 = i__ + (i__ + 1) * b_dim1; q__1.r = imeps.r + 1.f, q__1.i = imeps.i + 0.f; b[i__2].r = q__1.r, b[i__2].i = q__1.i; } else if (i__ > 1) { i__2 = i__ + (i__ - 1) * b_dim1; q__2.r = -1.f, q__2.i = 0.f; q__1.r = q__2.r - imeps.r, q__1.i = q__2.i - imeps.i; b[i__2].r = q__1.r, b[i__2].i = q__1.i; } } else { i__2 = i__ + i__ * b_dim1; q__1.r = 1.f - reeps.r, q__1.i = 0.f - reeps.i; b[i__2].r = q__1.r, b[i__2].i = q__1.i; if (i__ % 2 != 0 && i__ < *n) { i__2 = i__ + (i__ + 1) * b_dim1; d__1 = 2.; q__1.r = d__1 * imeps.r, q__1.i = d__1 * imeps.i; b[i__2].r = q__1.r, b[i__2].i = q__1.i; } else if (i__ > 1) { i__2 = i__ + (i__ - 1) * b_dim1; q__2.r = -imeps.r, q__2.i = -imeps.i; d__1 = 2.; q__1.r = d__1 * q__2.r, q__1.i = d__1 * q__2.i; b[i__2].r = q__1.r, b[i__2].i = q__1.i; } } /* L250: */ } } /* Compute rhs (C, F) */ cgemm_("N", "N", m, n, m, &c_b1, &a[a_offset], lda, &r__[r_offset], ldr, & c_b3, &c__[c_offset], ldc); q__1.r = -1.f, q__1.i = 0.f; cgemm_("N", "N", m, n, n, &q__1, &l[l_offset], ldl, &b[b_offset], ldb, & c_b1, &c__[c_offset], ldc); cgemm_("N", "N", m, n, m, &c_b1, &d__[d_offset], ldd, &r__[r_offset], ldr, &c_b3, &f[f_offset], ldf); q__1.r = -1.f, q__1.i = 0.f; cgemm_("N", "N", m, n, n, &q__1, &l[l_offset], ldl, &e[e_offset], lde, & c_b1, &f[f_offset], ldf); /* End of CLATM5 */ return 0; } /* clatm5_ */
the_stack_data/19416.c
#include <stdio.h> void bubble_sort(int array[], int size) { for(int i=1;i<size-1;i++) { for(int j=size-1;j>=i;j--) { if(array[j]<array[j-1]) { int sementara = array[j]; array[j] = array[j-1]; array[j-1] = sementara; } } } for (int i = 0; i < size; ++i) { printf("%d ", array[i]); } printf("\n\n"); } void exchange_sort(int data[], int size) { for (int i=0;i<size-1;i++) { for (int j=(i+1);j<size;j++) { if (data[i]>data[j]) { int sementara = data[i]; data[i] = data[j]; data[j] = sementara; } } } for (int i = 0; i < size; ++i) { printf("%d ", data[i]); } printf("\n\n"); } void main() { int data[]={23,65,30,8,33,24,76,7}; int size = sizeof(data) / sizeof(data[0]); printf("Bubble Sorting\n"); bubble_sort(data, size); printf("Exchange Sorting\n"); exchange_sort(data, size); }
the_stack_data/14201378.c
// PARAM: --disable ana.race.free // copy of 02-base/76-realloc with different PARAM #include <stdlib.h> #include <assert.h> #include <pthread.h> void test1_f() { assert(1); // reachable } void test1() { void (**fpp)(void) = malloc(sizeof(void(**)(void))); *fpp = &test1_f; fpp = realloc(fpp, sizeof(void(**)(void))); // same size // (*fpp)(); void (*fp)(void) = *fpp; fp(); // should call test1_f } void* test2_f(void *arg) { int *p = arg; *p = 1; // RACE! return NULL; } void test2() { int *p = malloc(sizeof(int)); pthread_t id; pthread_create(&id, NULL, test2_f, p); realloc(p, sizeof(int)); // RACE! } void* test3_f(void *arg) { int *p = arg; int x = *p; // NORACE return NULL; } void test3() { int *p = malloc(sizeof(int)); pthread_t id; pthread_create(&id, NULL, test3_f, p); realloc(p, sizeof(int)); // NORACE } int main() { test1(); test2(); test3(); return 0; }
the_stack_data/759855.c
/* $OpenBSD: memset.c,v 1.7 2015/08/31 02:53:57 guenther Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <string.h> void * memset(void *dst, int c, size_t n) { if (n != 0) { unsigned char *d = dst; do *d++ = (unsigned char)c; while (--n != 0); } return (dst); } DEF_STRONG(memset);
the_stack_data/206393954.c
/* vi: set sw=4 ts=4: */ /* * settimeofday() for uClibc * * Copyright (C) 2000-2006 Erik Andersen <[email protected]> * * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ #include <sys/syscall.h> #include <sys/time.h> #ifdef __USE_BSD _syscall2(int, settimeofday, const struct timeval *, tv, const struct timezone *, tz) libc_hidden_def(settimeofday) #endif
the_stack_data/137569.c
#1 "dct.c" #1 "dct.c" 1 #1 "<built-in>" 1 #1 "<built-in>" 3 #149 "<built-in>" 3 #1 "<command line>" 1 #1 "/opt/Xilinx/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" 1 /* autopilot_ssdm_op.h*/ /* #- (c) Copyright 2011-2017 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ * * $Id$ */ #289 "/opt/Xilinx/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" /*#define AP_SPEC_ATTR __attribute__ ((pure))*/ /****** SSDM Intrinsics: OPERATIONS ***/ // Interface operations //typedef unsigned int __attribute__ ((bitwidth(1))) _uint1_; void _ssdm_op_IfRead() __attribute__ ((nothrow)); void _ssdm_op_IfWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_op_IfNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanWrite() SSDM_OP_ATTR; // Stream Intrinsics void _ssdm_StreamRead() __attribute__ ((nothrow)); void _ssdm_StreamWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_StreamNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanWrite() SSDM_OP_ATTR; // Misc void _ssdm_op_MemShiftRead() __attribute__ ((nothrow)); void _ssdm_op_Wait() __attribute__ ((nothrow)); void _ssdm_op_Poll() __attribute__ ((nothrow)); void _ssdm_op_Return() __attribute__ ((nothrow)); /* SSDM Intrinsics: SPECIFICATIONS */ void _ssdm_op_SpecSynModule() __attribute__ ((nothrow)); void _ssdm_op_SpecTopModule() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDecl() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDef() __attribute__ ((nothrow)); void _ssdm_op_SpecPort() __attribute__ ((nothrow)); void _ssdm_op_SpecConnection() __attribute__ ((nothrow)); void _ssdm_op_SpecChannel() __attribute__ ((nothrow)); void _ssdm_op_SpecSensitive() __attribute__ ((nothrow)); void _ssdm_op_SpecModuleInst() __attribute__ ((nothrow)); void _ssdm_op_SpecPortMap() __attribute__ ((nothrow)); void _ssdm_op_SpecReset() __attribute__ ((nothrow)); void _ssdm_op_SpecPlatform() __attribute__ ((nothrow)); void _ssdm_op_SpecClockDomain() __attribute__ ((nothrow)); void _ssdm_op_SpecPowerDomain() __attribute__ ((nothrow)); int _ssdm_op_SpecRegionBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecRegionEnd() __attribute__ ((nothrow)); void _ssdm_op_SpecLoopName() __attribute__ ((nothrow)); void _ssdm_op_SpecLoopTripCount() __attribute__ ((nothrow)); int _ssdm_op_SpecStateBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecStateEnd() __attribute__ ((nothrow)); void _ssdm_op_SpecInterface() __attribute__ ((nothrow)); void _ssdm_op_SpecPipeline() __attribute__ ((nothrow)); void _ssdm_op_SpecDataflowPipeline() __attribute__ ((nothrow)); void _ssdm_op_SpecLatency() __attribute__ ((nothrow)); void _ssdm_op_SpecParallel() __attribute__ ((nothrow)); void _ssdm_op_SpecProtocol() __attribute__ ((nothrow)); void _ssdm_op_SpecOccurrence() __attribute__ ((nothrow)); void _ssdm_op_SpecResource() __attribute__ ((nothrow)); void _ssdm_op_SpecResourceLimit() __attribute__ ((nothrow)); void _ssdm_op_SpecCHCore() __attribute__ ((nothrow)); void _ssdm_op_SpecFUCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIFCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIPCore() __attribute__ ((nothrow)); void _ssdm_op_SpecKeepValue() __attribute__ ((nothrow)); void _ssdm_op_SpecMemCore() __attribute__ ((nothrow)); void _ssdm_op_SpecExt() __attribute__ ((nothrow)); /*void* _ssdm_op_SpecProcess() SSDM_SPEC_ATTR; void* _ssdm_op_SpecEdge() SSDM_SPEC_ATTR; */ /* Presynthesis directive functions */ void _ssdm_SpecArrayDimSize() __attribute__ ((nothrow)); void _ssdm_RegionBegin() __attribute__ ((nothrow)); void _ssdm_RegionEnd() __attribute__ ((nothrow)); void _ssdm_Unroll() __attribute__ ((nothrow)); void _ssdm_UnrollRegion() __attribute__ ((nothrow)); void _ssdm_InlineAll() __attribute__ ((nothrow)); void _ssdm_InlineLoop() __attribute__ ((nothrow)); void _ssdm_Inline() __attribute__ ((nothrow)); void _ssdm_InlineSelf() __attribute__ ((nothrow)); void _ssdm_InlineRegion() __attribute__ ((nothrow)); void _ssdm_SpecArrayMap() __attribute__ ((nothrow)); void _ssdm_SpecArrayPartition() __attribute__ ((nothrow)); void _ssdm_SpecArrayReshape() __attribute__ ((nothrow)); void _ssdm_SpecStream() __attribute__ ((nothrow)); void _ssdm_SpecExpr() __attribute__ ((nothrow)); void _ssdm_SpecExprBalance() __attribute__ ((nothrow)); void _ssdm_SpecDependence() __attribute__ ((nothrow)); void _ssdm_SpecLoopMerge() __attribute__ ((nothrow)); void _ssdm_SpecLoopFlatten() __attribute__ ((nothrow)); void _ssdm_SpecLoopRewind() __attribute__ ((nothrow)); void _ssdm_SpecFuncInstantiation() __attribute__ ((nothrow)); void _ssdm_SpecFuncBuffer() __attribute__ ((nothrow)); void _ssdm_SpecFuncExtract() __attribute__ ((nothrow)); void _ssdm_SpecConstant() __attribute__ ((nothrow)); void _ssdm_DataPack() __attribute__ ((nothrow)); void _ssdm_SpecDataPack() __attribute__ ((nothrow)); void _ssdm_op_SpecBitsMap() __attribute__ ((nothrow)); void _ssdm_op_SpecLicense() __attribute__ ((nothrow)); /*#define _ssdm_op_WaitUntil(X) while (!(X)) _ssdm_op_Wait(1); #define _ssdm_op_Delayed(X) X */ #427 "/opt/Xilinx/Vivado_HLS/2017.1/common/technology/autopilot/etc/autopilot_ssdm_op.h" // 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 #6 "<command line>" 2 #1 "<built-in>" 2 #1 "dct.c" 2 #1 "./dct.h" 1 typedef short dct_data_t; void dct(short input[1024/16], short output[1024/16]); #3 "dct.c" 2 void dct_1d(dct_data_t src[8 /* defines the input matrix as 8x8 */], dct_data_t dst[8 /* defines the input matrix as 8x8 */]) {_ssdm_SpecArrayDimSize(dst,8);_ssdm_SpecArrayDimSize(src,8); unsigned int k, n; int tmp; const dct_data_t dct_coeff_table[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */] = { #1 "./dct_coeff_table.txt" 1 8192, 8192, 8192, 8192, 8192, 8192, 8192, 8192, 11363, 9633, 6436, 2260, -2260, -6436, -9632,-11362, 10703, 4433, -4433,-10703,-10703, -4433, 4433, 10703, 9633, -2260,-11362, -6436, 6436, 11363, 2260, -9632, 8192, -8192, -8192, 8192, 8192, -8191, -8191, 8192, 6436,-11362, 2260, 9633, -9632, -2260, 11363, -6436, 4433,-10703, 10703, -4433, -4433, 10703,-10703, 4433, 2260, -6436, 9633,-11362, 11363, -9632, 6436, -2260 #10 "dct.c" 2 }; _ssdm_SpecConstant(dct_coeff_table); #10 "dct.c" DCT_Outer_Loop: for (k = 0; k < 8 /* defines the input matrix as 8x8 */; k++) { DCT_Inner_Loop: for(n = 0, tmp = 0; n < 8 /* defines the input matrix as 8x8 */; n++) { int coeff = (int)dct_coeff_table[k][n]; tmp += src[n] * coeff; } dst[k] = (((tmp) + (1 << ((13)-1))) >> 13); } } void dct_2d(dct_data_t in_block[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */], dct_data_t out_block[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */]) {_ssdm_SpecArrayDimSize(out_block,8);_ssdm_SpecArrayDimSize(in_block,8); dct_data_t row_outbuf[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */]; dct_data_t col_outbuf[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */], col_inbuf[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */]; unsigned i, j; // DCT rows Row_DCT_Loop: for(i = 0; i < 8 /* defines the input matrix as 8x8 */; i++) { dct_1d(in_block[i], row_outbuf[i]); } // Transpose data in order to re-use 1D DCT code Xpose_Row_Outer_Loop: for (j = 0; j < 8 /* defines the input matrix as 8x8 */; j++) Xpose_Row_Inner_Loop: for(i = 0; i < 8 /* defines the input matrix as 8x8 */; i++) col_inbuf[j][i] = row_outbuf[i][j]; // DCT columns Col_DCT_Loop: for (i = 0; i < 8 /* defines the input matrix as 8x8 */; i++) { dct_1d(col_inbuf[i], col_outbuf[i]); } // Transpose data back into natural order Xpose_Col_Outer_Loop: for (j = 0; j < 8 /* defines the input matrix as 8x8 */; j++) Xpose_Col_Inner_Loop: for(i = 0; i < 8 /* defines the input matrix as 8x8 */; i++) out_block[j][i] = col_outbuf[i][j]; } void read_data(short input[1024/16], short buf[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */]) {_ssdm_SpecArrayDimSize(input,1024/16);_ssdm_SpecArrayDimSize(buf,8); int r, c; RD_Loop_Row: for (r = 0; r < 8 /* defines the input matrix as 8x8 */; r++) { RD_Loop_Col: for (c = 0; c < 8 /* defines the input matrix as 8x8 */; c++) buf[r][c] = input[r * 8 /* defines the input matrix as 8x8 */ + c]; } } void write_data(short buf[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */], short output[1024/16]) {_ssdm_SpecArrayDimSize(output,1024/16);_ssdm_SpecArrayDimSize(buf,8); int r, c; WR_Loop_Row: for (r = 0; r < 8 /* defines the input matrix as 8x8 */; r++) { WR_Loop_Col: for (c = 0; c < 8 /* defines the input matrix as 8x8 */; c++) output[r * 8 /* defines the input matrix as 8x8 */ + c] = buf[r][c]; } } void dct(short input[1024/16], short output[1024/16]) {_ssdm_SpecArrayDimSize(output,1024/16);_ssdm_SpecArrayDimSize(input,1024/16); short buf_2d_in[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */]; short buf_2d_out[8 /* defines the input matrix as 8x8 */][8 /* defines the input matrix as 8x8 */]; // Read input data. Fill the internal buffer. read_data(input, buf_2d_in); dct_2d(buf_2d_in, buf_2d_out); // Write out the results. write_data(buf_2d_out, output); }
the_stack_data/56912.c
#include <stdio.h> int main() { printf("Hello"); return 0; }
the_stack_data/731217.c
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <termios.h> #include <unistd.h> int main() { char buf[1000]; struct termios T; #if 1 tcgetattr(0, &T); cfmakeraw(&T); // Turn off ICANON T.c_lflag |= ECHO; // But leave ECHO on tcsetattr(0, TCSANOW, &T); #else system("stty raw"); #endif while (1) { // We should get 1 char int i=read(0, buf, 1000); // at a time if (i<1) { write(2, ".", 1); sleep(1); } else { if (buf[0]==4) exit(0); // Stop on leading ctrl-D write(2, buf, i); } } }
the_stack_data/28263324.c
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { int a, b; float c,d; scanf("%d", &a); scanf("%d", &b); printf("%d %d\n", a + b, a - b); scanf("%f", &c); scanf("%f", &d); printf("%.1f %.1f", c + d , c - d); return 0; }
the_stack_data/98575313.c
#include <stdio.h> int main() { int n, i, j, temp,item,flag=0,low,high,mid; int arr[64]; printf("Enter number of elements\n"); scanf("%d", &n); printf("Enter %d integers\n", n); for (i = 0; i < n; i++) { scanf("%d", &arr[i]); } for (i = 1 ; i <= n - 1; i++) { j = i; while ( j > 0 && arr[j-1] > arr[j]) { temp = arr[j]; arr[j] = arr[j-1]; arr[j-1] = temp; j--; } } printf("Sorted list in ascending order:\n"); for (i = 0; i <= n - 1; i++) { printf("%d\n", arr[i]); } printf("\n Enter the number to be search: "); scanf("%d",&item); low=0,high=n-1; while(low<=high) { mid=(low+high)/2; if(item==arr[mid]) { flag=1; break; } else if(item<arr[mid]) { high=mid-1; } else low=mid+1; } if(flag==0) printf("\n The number is not found"); else printf("\n The number is found and its position is: %d",mid+1); return 0; }
the_stack_data/36074564.c
#if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng * Last changed in libpng 1.6.15 [November 20, 2014] * Maintained 1998-2014 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * To the extent possible under law, the authors have waived * all copyright and related or neighboring rights to this file. * This work is published from: United States. */ /* This is an example of how to use libpng to read and write PNG files. * The file libpng-manual.txt is much more verbose then this. If you have not * read it, do so first. This was designed to be a starting point of an * implementation. This is not officially part of libpng, is hereby placed * in the public domain, and therefore does not require a copyright notice. * * This file does not currently compile, because it is missing certain * parts, like allocating memory to hold an image. You will have to * supply these parts to get it to compile. For an example of a minimal * working PNG reader/writer, see pngtest.c, included in this distribution; * see also the programs in the contrib directory. */ /* The simple, but restricted, approach to reading a PNG file or data stream * just requires two function calls, as in the following complete program. * Writing a file just needs one function call, so long as the data has an * appropriate layout. * * The following code reads PNG image data from a file and writes it, in a * potentially new format, to a new file. While this code will compile there is * minimal (insufficient) error checking; for a more realistic version look at * contrib/examples/pngtopng.c */ #include <stddef.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <png.h> #include <zlib.h> int main(int argc, const char **argv) { if (argc == 3) { png_image image; /* The control structure used by libpng */ /* Initialize the 'png_image' structure. */ memset(&image, 0, (sizeof image)); image.version = PNG_IMAGE_VERSION; /* The first argument is the file to read: */ if (png_image_begin_read_from_file(&image, argv[1]) != 0) { png_bytep buffer; /* Set the format in which to read the PNG file; this code chooses a * simple sRGB format with a non-associated alpha channel, adequate to * store most images. */ image.format = PNG_FORMAT_RGBA; /* Now allocate enough memory to hold the image in this format; the * PNG_IMAGE_SIZE macro uses the information about the image (width, * height and format) stored in 'image'. */ buffer = malloc(PNG_IMAGE_SIZE(image)); /* If enough memory was available read the image in the desired format * then write the result out to the new file. 'background' is not * necessary when reading the image because the alpha channel is * preserved; if it were to be removed, for example if we requested * PNG_FORMAT_RGB, then either a solid background color would have to * be supplied or the output buffer would have to be initialized to the * actual background of the image. * * The fourth argument to png_image_finish_read is the 'row_stride' - * this is the number of components allocated for the image in each * row. It has to be at least as big as the value returned by * PNG_IMAGE_ROW_STRIDE, but if you just allocate space for the * default, minimum, size using PNG_IMAGE_SIZE as above you can pass * zero. * * The final argument is a pointer to a buffer for the colormap; * colormaps have exactly the same format as a row of image pixels (so * you choose what format to make the colormap by setting * image.format). A colormap is only returned if * PNG_FORMAT_FLAG_COLORMAP is also set in image.format, so in this * case NULL is passed as the final argument. If you do want to force * all images into an index/color-mapped format then you can use: * * PNG_IMAGE_COLORMAP_SIZE(image) * * to find the maximum size of the colormap in bytes. */ if (buffer != NULL && png_image_finish_read(&image, NULL/*background*/, buffer, 0/*row_stride*/, NULL/*colormap*/) != 0) { /* Now write the image out to the second argument. In the write * call 'convert_to_8bit' allows 16-bit data to be squashed down to * 8 bits; this isn't necessary here because the original read was * to the 8-bit format. */ if (png_image_write_to_file(&image, argv[2], 0/*convert_to_8bit*/, buffer, 0/*row_stride*/, NULL/*colormap*/) != 0) { /* The image has been written successfully. */ exit(0); } } else { /* Calling png_free_image is optional unless the simplified API was * not run to completion. In this case if there wasn't enough * memory for 'buffer' we didn't complete the read, so we must free * the image: */ if (buffer == NULL) png_free_image(&image); else free(buffer); } /* Something went wrong reading or writing the image. libpng stores a * textual message in the 'png_image' structure: */ fprintf(stderr, "pngtopng: error: %s\n", image.message); exit (1); } fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n"); exit(1); } /* That's it ;-) Of course you probably want to do more with PNG files than * just converting them all to 32-bit RGBA PNG files; you can do that between * the call to png_image_finish_read and png_image_write_to_file. You can also * ask for the image data to be presented in a number of different formats. You * do this by simply changing the 'format' parameter set before allocating the * buffer. * * The format parameter consists of five flags that define various aspects of * the image, you can simply add these together to get the format or you can use * one of the predefined macros from png.h (as above): * * PNG_FORMAT_FLAG_COLOR: if set the image will have three color components per * pixel (red, green and blue), if not set the image will just have one * luminance (grayscale) component. * * PNG_FORMAT_FLAG_ALPHA: if set each pixel in the image will have an additional * alpha value; a linear value that describes the degree the image pixel * covers (overwrites) the contents of the existing pixel on the display. * * PNG_FORMAT_FLAG_LINEAR: if set the components of each pixel will be returned * as a series of 16-bit linear values, if not set the components will be * returned as a series of 8-bit values encoded according to the 'sRGB' * standard. The 8-bit format is the normal format for images intended for * direct display, because almost all display devices do the inverse of the * sRGB transformation to the data they receive. The 16-bit format is more * common for scientific data and image data that must be further processed; * because it is linear simple math can be done on the component values. * Regardless of the setting of this flag the alpha channel is always linear, * although it will be 8 bits or 16 bits wide as specified by the flag. * * PNG_FORMAT_FLAG_BGR: if set the components of a color pixel will be returned * in the order blue, then green, then red. If not set the pixel components * are in the order red, then green, then blue. * * PNG_FORMAT_FLAG_AFIRST: if set the alpha channel (if present) precedes the * color or grayscale components. If not set the alpha channel follows the * components. * * You do not have to read directly from a file. You can read from memory or, * on systems that support it, from a <stdio.h> FILE*. This is controlled by * the particular png_image_read_from_ function you call at the start. Likewise * on write you can write to a FILE* if your system supports it. Check the * macro PNG_STDIO_SUPPORTED to see if stdio support has been included in your * libpng build. * * If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data you may need to write it in * the 8-bit format for display. You do this by setting the convert_to_8bit * flag to 'true'. * * Don't repeatedly convert between the 8-bit and 16-bit forms. There is * significant data loss when 16-bit data is converted to the 8-bit encoding and * the current libpng implementation of conversion to 16-bit is also * significantly lossy. The latter will be fixed in the future, but the former * is unavoidable - the 8-bit format just doesn't have enough resolution. */ /* If your program needs more information from the PNG data it reads, or if you * need to do more complex transformations, or minimize transformations, on the * data you read, then you must use one of the several lower level libpng * interfaces. * * All these interfaces require that you do your own error handling - your * program must be able to arrange for control to return to your own code any * time libpng encounters a problem. There are several ways to do this, but the * standard way is to use the ANSI-C (C90) <setjmp.h> interface to establish a * return point within your own code. You must do this if you do not use the * simplified interface (above). * * The first step is to include the header files you need, including the libpng * header file. Include any standard headers and feature test macros your * program requires before including png.h: */ #include <png.h> /* The png_jmpbuf() macro, used in error handling, became available in * libpng version 1.0.6. If you want to be able to run your code with older * versions of libpng, you must define the macro yourself (but only if it * is not already defined by libpng!). */ #ifndef png_jmpbuf # define png_jmpbuf(png_ptr) ((png_ptr)->png_jmpbuf) #endif /* Check to see if a file is a PNG file using png_sig_cmp(). png_sig_cmp() * returns zero if the image is a PNG and nonzero if it isn't a PNG. * * The function check_if_png() shown here, but not used, returns nonzero (true) * if the file can be opened and is a PNG, 0 (false) otherwise. * * If this call is successful, and you are going to keep the file open, * you should call png_set_sig_bytes(png_ptr, PNG_BYTES_TO_CHECK); once * you have created the png_ptr, so that libpng knows your application * has read that many bytes from the start of the file. Make sure you * don't call png_set_sig_bytes() with more than 8 bytes read or give it * an incorrect number of bytes read, or you will either have read too * many bytes (your fault), or you are telling libpng to read the wrong * number of magic bytes (also your fault). * * Many applications already read the first 2 or 4 bytes from the start * of the image to determine the file type, so it would be easiest just * to pass the bytes to png_sig_cmp() or even skip that if you know * you have a PNG file, and call png_set_sig_bytes(). */ #define PNG_BYTES_TO_CHECK 4 int check_if_png(char *file_name, FILE **fp) { char buf[PNG_BYTES_TO_CHECK]; /* Open the prospective PNG file. */ if ((*fp = fopen(file_name, "rb")) == NULL) return 0; /* Read in some of the signature bytes */ if (fread(buf, 1, PNG_BYTES_TO_CHECK, *fp) != PNG_BYTES_TO_CHECK) return 0; /* Compare the first PNG_BYTES_TO_CHECK bytes of the signature. Return nonzero (true) if they match */ return(!png_sig_cmp(buf, (png_size_t)0, PNG_BYTES_TO_CHECK)); } /* Read a PNG file. You may want to return an error code if the read * fails (depending upon the failure). There are two "prototypes" given * here - one where we are given the filename, and we need to open the * file, and the other where we are given an open file (possibly with * some or all of the magic bytes read - see comments above). */ #ifdef open_file /* prototype 1 */ void read_png(char *file_name) /* We need to open the file */ { png_structp png_ptr; png_infop info_ptr; unsigned int sig_read = 0; png_uint_32 width, height; int bit_depth, color_type, interlace_type; FILE *fp; if ((fp = fopen(file_name, "rb")) == NULL) return (ERROR); #else no_open_file /* prototype 2 */ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ { png_structp png_ptr; png_infop info_ptr; png_uint_32 width, height; int bit_depth, color_type, interlace_type; #endif no_open_file /* Only use one prototype! */ /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, * you can supply NULL for the last three parameters. We also supply the * the compiler header file version, so that we know if the application * was compiled with a compatible version of the library. REQUIRED */ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp user_error_ptr, user_error_fn, user_warning_fn); if (png_ptr == NULL) { fclose(fp); return (ERROR); } /* Allocate/initialize the memory for image information. REQUIRED. */ info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { fclose(fp); png_destroy_read_struct(&png_ptr, NULL, NULL); return (ERROR); } /* Set error handling if you are using the setjmp/longjmp method (this is * the normal method of doing things with libpng). REQUIRED unless you * set up your own error handlers in the png_create_read_struct() earlier. */ if (setjmp(png_jmpbuf(png_ptr))) { /* Free all of the memory associated with the png_ptr and info_ptr */ png_destroy_read_struct(&png_ptr, &info_ptr, NULL); fclose(fp); /* If we get here, we had a problem reading the file */ return (ERROR); } /* One of the following I/O initialization methods is REQUIRED */ #ifdef streams /* PNG file I/O method 1 */ /* Set up the input control if you are using standard C streams */ png_init_io(png_ptr, fp); #else no_streams /* PNG file I/O method 2 */ /* If you are using replacement read functions, instead of calling * png_init_io() here you would call: */ png_set_read_fn(png_ptr, (void *)user_io_ptr, user_read_fn); /* where user_io_ptr is a structure you want available to the callbacks */ #endif no_streams /* Use only one I/O method! */ /* If we have already read some of the signature */ png_set_sig_bytes(png_ptr, sig_read); #ifdef hilevel /* * If you have enough memory to read in the entire image at once, * and you need to specify only transforms that can be controlled * with one of the PNG_TRANSFORM_* bits (this presently excludes * quantizing, filling, setting background, and doing gamma * adjustment), then you can read the entire image (including * pixels) into the info structure with this call: */ png_read_png(png_ptr, info_ptr, png_transforms, NULL); #else /* OK, you're doing it the hard way, with the lower-level functions */ /* The call to png_read_info() gives us all of the information from the * PNG file before the first IDAT (image data chunk). REQUIRED */ png_read_info(png_ptr, info_ptr); png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL); /* Set up the data transformations you want. Note that these are all * optional. Only call them if you want/need them. Many of the * transformations only work on specific types of images, and many * are mutually exclusive. */ /* Tell libpng to strip 16 bit/color files down to 8 bits/color. * Use accurate scaling if it's available, otherwise just chop off the * low byte. */ #ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED png_set_scale_16(png_ptr); #else png_set_strip_16(png_ptr); #endif /* Strip alpha bytes from the input data without combining with the * background (not recommended). */ png_set_strip_alpha(png_ptr); /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single * byte into separate bytes (useful for paletted and grayscale images). */ png_set_packing(png_ptr); /* Change the order of packed pixels to least significant bit first * (not useful if you are using png_set_packing). */ png_set_packswap(png_ptr); /* Expand paletted colors into true RGB triplets */ if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png_ptr); /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); /* Expand paletted or RGB images with transparency to full alpha channels * so the data will be available as RGBA quartets. */ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) != 0) png_set_tRNS_to_alpha(png_ptr); /* Set the background color to draw transparent and alpha images over. * It is possible to set the red, green, and blue components directly * for paletted images instead of supplying a palette index. Note that * even if the PNG file supplies a background, you are not required to * use it - you should use the (solid) application background if it has one. */ png_color_16 my_background, *image_background; if (png_get_bKGD(png_ptr, info_ptr, &image_background) != 0) png_set_background(png_ptr, image_background, PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); else png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); /* Some suggestions as to how to get a screen gamma value * * Note that screen gamma is the display_exponent, which includes * the CRT_exponent and any correction for viewing conditions */ if (/* We have a user-defined screen gamma value */) { screen_gamma = user-defined screen_gamma; } /* This is one way that applications share the same screen gamma value */ else if ((gamma_str = getenv("SCREEN_GAMMA")) != NULL) { screen_gamma = atof(gamma_str); } /* If we don't have another value */ else { screen_gamma = PNG_DEFAULT_sRGB; /* A good guess for a PC monitor in a dimly lit room */ screen_gamma = PNG_GAMMA_MAC_18 or 1.0; /* Good guesses for Mac systems */ } /* Tell libpng to handle the gamma conversion for you. The final call * is a good guess for PC generated images, but it should be configurable * by the user at run time by the user. It is strongly suggested that * your application support gamma correction. */ int intent; if (png_get_sRGB(png_ptr, info_ptr, &intent) != 0) png_set_gamma(png_ptr, screen_gamma, PNG_DEFAULT_sRGB); else { double image_gamma; if (png_get_gAMA(png_ptr, info_ptr, &image_gamma) != 0) png_set_gamma(png_ptr, screen_gamma, image_gamma); else png_set_gamma(png_ptr, screen_gamma, 0.45455); } #ifdef PNG_READ_QUANTIZE_SUPPORTED /* Quantize RGB files down to 8 bit palette or reduce palettes * to the number of colors available on your screen. */ if ((color_type & PNG_COLOR_MASK_COLOR) != 0) { int num_palette; png_colorp palette; /* This reduces the image to the application supplied palette */ if (/* We have our own palette */) { /* An array of colors to which the image should be quantized */ png_color std_color_cube[MAX_SCREEN_COLORS]; png_set_quantize(png_ptr, std_color_cube, MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, NULL, 0); } /* This reduces the image to the palette supplied in the file */ else if (png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) != 0) { png_uint_16p histogram = NULL; png_get_hIST(png_ptr, info_ptr, &histogram); png_set_quantize(png_ptr, palette, num_palette, max_screen_colors, histogram, 0); } } #endif /* READ_QUANTIZE */ /* Invert monochrome files to have 0 as white and 1 as black */ png_set_invert_mono(png_ptr); /* If you want to shift the pixel values from the range [0,255] or * [0,65535] to the original [0,7] or [0,31], or whatever range the * colors were originally in: */ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT) != 0) { png_color_8p sig_bit_p; png_get_sBIT(png_ptr, info_ptr, &sig_bit_p); png_set_shift(png_ptr, sig_bit_p); } /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ if ((color_type & PNG_COLOR_MASK_COLOR) != 0) png_set_bgr(png_ptr); /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ png_set_swap_alpha(png_ptr); /* Swap bytes of 16 bit files to least significant byte first */ png_set_swap(png_ptr); /* Add filler (or alpha) byte (before/after each RGB triplet) */ png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); #ifdef PNG_READ_INTERLACING_SUPPORTED /* Turn on interlace handling. REQUIRED if you are not using * png_read_image(). To see how to handle interlacing passes, * see the png_read_row() method below: */ number_passes = png_set_interlace_handling(png_ptr); #else number_passes = 1; #endif /* READ_INTERLACING */ /* Optional call to gamma correct and add the background to the palette * and update info structure. REQUIRED if you are expecting libpng to * update the palette for you (ie you selected such a transform above). */ png_read_update_info(png_ptr, info_ptr); /* Allocate the memory to hold the image using the fields of info_ptr. */ /* The easiest way to read the image: */ png_bytep row_pointers[height]; /* Clear the pointer array */ for (row = 0; row < height; row++) row_pointers[row] = NULL; for (row = 0; row < height; row++) row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); /* Now it's time to read the image. One of these methods is REQUIRED */ #ifdef entire /* Read the entire image in one go */ png_read_image(png_ptr, row_pointers); #else no_entire /* Read the image one or more scanlines at a time */ /* The other way to read images - deal with interlacing: */ for (pass = 0; pass < number_passes; pass++) { #ifdef single /* Read the image a single row at a time */ for (y = 0; y < height; y++) { png_read_rows(png_ptr, &row_pointers[y], NULL, 1); } #else no_single /* Read the image several rows at a time */ for (y = 0; y < height; y += number_of_rows) { #ifdef sparkle /* Read the image using the "sparkle" effect. */ png_read_rows(png_ptr, &row_pointers[y], NULL, number_of_rows); #else no_sparkle /* Read the image using the "rectangle" effect */ png_read_rows(png_ptr, NULL, &row_pointers[y], number_of_rows); #endif no_sparkle /* Use only one of these two methods */ } /* If you want to display the image after every pass, do so here */ #endif no_single /* Use only one of these two methods */ } #endif no_entire /* Use only one of these two methods */ /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); #endif hilevel /* At this point you have read the entire image */ /* Clean up after the read, and free any memory allocated - REQUIRED */ png_destroy_read_struct(&png_ptr, &info_ptr, NULL); /* Close the file */ fclose(fp); /* That's it */ return (OK); } /* Progressively read a file */ int initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) { /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, * you can supply NULL for the last three parameters. We also check that * the library version is compatible in case we are using dynamically * linked libraries. */ *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp user_error_ptr, user_error_fn, user_warning_fn); if (*png_ptr == NULL) { *info_ptr = NULL; return (ERROR); } *info_ptr = png_create_info_struct(png_ptr); if (*info_ptr == NULL) { png_destroy_read_struct(png_ptr, info_ptr, NULL); return (ERROR); } if (setjmp(png_jmpbuf((*png_ptr)))) { png_destroy_read_struct(png_ptr, info_ptr, NULL); return (ERROR); } /* This one's new. You will need to provide all three * function callbacks, even if you aren't using them all. * If you aren't using all functions, you can specify NULL * parameters. Even when all three functions are NULL, * you need to call png_set_progressive_read_fn(). * These functions shouldn't be dependent on global or * static variables if you are decoding several images * simultaneously. You should store stream specific data * in a separate struct, given as the second parameter, * and retrieve the pointer from inside the callbacks using * the function png_get_progressive_ptr(png_ptr). */ png_set_progressive_read_fn(*png_ptr, (void *)stream_data, info_callback, row_callback, end_callback); return (OK); } int process_data(png_structp *png_ptr, png_infop *info_ptr, png_bytep buffer, png_uint_32 length) { if (setjmp(png_jmpbuf((*png_ptr)))) { /* Free the png_ptr and info_ptr memory on error */ png_destroy_read_struct(png_ptr, info_ptr, NULL); return (ERROR); } /* This one's new also. Simply give it chunks of data as * they arrive from the data stream (in order, of course). * On segmented machines, don't give it any more than 64K. * The library seems to run fine with sizes of 4K, although * you can give it much less if necessary (I assume you can * give it chunks of 1 byte, but I haven't tried with less * than 256 bytes yet). When this function returns, you may * want to display any rows that were generated in the row * callback, if you aren't already displaying them there. */ png_process_data(*png_ptr, *info_ptr, buffer, length); return (OK); } info_callback(png_structp png_ptr, png_infop info) { /* Do any setup here, including setting any of the transformations * mentioned in the Reading PNG files section. For now, you _must_ * call either png_start_read_image() or png_read_update_info() * after all the transformations are set (even if you don't set * any). You may start getting rows before png_process_data() * returns, so this is your last chance to prepare for that. */ } row_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass) { /* * This function is called for every row in the image. If the * image is interlaced, and you turned on the interlace handler, * this function will be called for every row in every pass. * * In this function you will receive a pointer to new row data from * libpng called new_row that is to replace a corresponding row (of * the same data format) in a buffer allocated by your application. * * The new row data pointer "new_row" may be NULL, indicating there is * no new data to be replaced (in cases of interlace loading). * * If new_row is not NULL then you need to call * png_progressive_combine_row() to replace the corresponding row as * shown below: */ /* Get pointer to corresponding row in our * PNG read buffer. */ png_bytep old_row = ((png_bytep *)our_data)[row_num]; #ifdef PNG_READ_INTERLACING_SUPPORTED /* If both rows are allocated then copy the new row * data to the corresponding row data. */ if ((old_row != NULL) && (new_row != NULL)) png_progressive_combine_row(png_ptr, old_row, new_row); /* * The rows and passes are called in order, so you don't really * need the row_num and pass, but I'm supplying them because it * may make your life easier. * * For the non-NULL rows of interlaced images, you must call * png_progressive_combine_row() passing in the new row and the * old row, as demonstrated above. You can call this function for * NULL rows (it will just return) and for non-interlaced images * (it just does the memcpy for you) if it will make the code * easier. Thus, you can just do this for all cases: */ png_progressive_combine_row(png_ptr, old_row, new_row); /* where old_row is what was displayed for previous rows. Note * that the first pass (pass == 0 really) will completely cover * the old row, so the rows do not have to be initialized. After * the first pass (and only for interlaced images), you will have * to pass the current row as new_row, and the function will combine * the old row and the new row. */ #endif /* READ_INTERLACING */ } end_callback(png_structp png_ptr, png_infop info) { /* This function is called when the whole image has been read, * including any chunks after the image (up to and including * the IEND). You will usually have the same info chunk as you * had in the header, although some data may have been added * to the comments and time fields. * * Most people won't do much here, perhaps setting a flag that * marks the image as finished. */ } /* Write a png file */ void write_png(char *file_name /* , ... other image information ... */) { FILE *fp; png_structp png_ptr; png_infop info_ptr; png_colorp palette; /* Open the file */ fp = fopen(file_name, "wb"); if (fp == NULL) return (ERROR); /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, * you can supply NULL for the last three parameters. We also check that * the library version is compatible with the one used at compile time, * in case we are using dynamically linked libraries. REQUIRED. */ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp user_error_ptr, user_error_fn, user_warning_fn); if (png_ptr == NULL) { fclose(fp); return (ERROR); } /* Allocate/initialize the image information data. REQUIRED */ info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { fclose(fp); png_destroy_write_struct(&png_ptr, NULL); return (ERROR); } /* Set error handling. REQUIRED if you aren't supplying your own * error handling functions in the png_create_write_struct() call. */ if (setjmp(png_jmpbuf(png_ptr))) { /* If we get here, we had a problem writing the file */ fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); return (ERROR); } /* One of the following I/O initialization functions is REQUIRED */ #ifdef streams /* I/O initialization method 1 */ /* Set up the output control if you are using standard C streams */ png_init_io(png_ptr, fp); #else no_streams /* I/O initialization method 2 */ /* If you are using replacement write functions, instead of calling * png_init_io() here you would call */ png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, user_IO_flush_function); /* where user_io_ptr is a structure you want available to the callbacks */ #endif no_streams /* Only use one initialization method */ #ifdef hilevel /* This is the easy way. Use it if you already have all the * image info living in the structure. You could "|" many * PNG_TRANSFORM flags into the png_transforms integer here. */ png_write_png(png_ptr, info_ptr, png_transforms, NULL); #else /* This is the hard way */ /* Set the image information here. Width and height are up to 2^31, * bit_depth is one of 1, 2, 4, 8, or 16, but valid values also depend on * the color_type selected. color_type is one of PNG_COLOR_TYPE_GRAY, * PNG_COLOR_TYPE_GRAY_ALPHA, PNG_COLOR_TYPE_PALETTE, PNG_COLOR_TYPE_RGB, * or PNG_COLOR_TYPE_RGB_ALPHA. interlace is either PNG_INTERLACE_NONE or * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED */ png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); /* Set the palette if there is one. REQUIRED for indexed-color images */ palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))); /* ... Set palette colors ... */ png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); /* You must not free palette here, because png_set_PLTE only makes a link to * the palette that you malloced. Wait until you are about to destroy * the png structure. */ /* Optional significant bit (sBIT) chunk */ png_color_8 sig_bit; /* If we are dealing with a grayscale image then */ sig_bit.gray = true_bit_depth; /* Otherwise, if we are dealing with a color image then */ sig_bit.red = true_red_bit_depth; sig_bit.green = true_green_bit_depth; sig_bit.blue = true_blue_bit_depth; /* If the image has an alpha channel then */ sig_bit.alpha = true_alpha_bit_depth; png_set_sBIT(png_ptr, info_ptr, &sig_bit); /* Optional gamma chunk is strongly suggested if you have any guess * as to the correct gamma of the image. */ png_set_gAMA(png_ptr, info_ptr, gamma); /* Optionally write comments into the image */ { png_text text_ptr[3]; char key0[]="Title"; char text0[]="Mona Lisa"; text_ptr[0].key = key0; text_ptr[0].text = text0; text_ptr[0].compression = PNG_TEXT_COMPRESSION_NONE; text_ptr[0].itxt_length = 0; text_ptr[0].lang = NULL; text_ptr[0].lang_key = NULL; char key1[]="Author"; char text1[]="Leonardo DaVinci"; text_ptr[1].key = key1; text_ptr[1].text = text1; text_ptr[1].compression = PNG_TEXT_COMPRESSION_NONE; text_ptr[1].itxt_length = 0; text_ptr[1].lang = NULL; text_ptr[1].lang_key = NULL; char key2[]="Description"; char text2[]="<long text>"; text_ptr[2].key = key2; text_ptr[2].text = text2; text_ptr[2].compression = PNG_TEXT_COMPRESSION_zTXt; text_ptr[2].itxt_length = 0; text_ptr[2].lang = NULL; text_ptr[2].lang_key = NULL; png_set_text(write_ptr, write_info_ptr, text_ptr, 3); } /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */ /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored * on read and, if your application chooses to write them, they must * be written in accordance with the sRGB profile */ /* Write the file header information. REQUIRED */ png_write_info(png_ptr, info_ptr); /* If you want, you can write the info in two steps, in case you need to * write your private chunk ahead of PLTE: * * png_write_info_before_PLTE(write_ptr, write_info_ptr); * write_my_chunk(); * png_write_info(png_ptr, info_ptr); * * However, given the level of known- and unknown-chunk support in 1.2.0 * and up, this should no longer be necessary. */ /* Once we write out the header, the compression type on the text * chunk gets changed to PNG_TEXT_COMPRESSION_NONE_WR or * PNG_TEXT_COMPRESSION_zTXt_WR, so it doesn't get written out again * at the end. */ /* Set up the transformations you want. Note that these are * all optional. Only call them if you want them. */ /* Invert monochrome pixels */ png_set_invert_mono(png_ptr); /* Shift the pixels up to a legal bit depth and fill in * as appropriate to correctly scale the image. */ png_set_shift(png_ptr, &sig_bit); /* Pack pixels into bytes */ png_set_packing(png_ptr); /* Swap location of alpha bytes from ARGB to RGBA */ png_set_swap_alpha(png_ptr); /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels). The second parameter is not used. */ png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); /* Flip BGR pixels to RGB */ png_set_bgr(png_ptr); /* Swap bytes of 16-bit files to most significant byte first */ png_set_swap(png_ptr); /* Swap bits of 1, 2, 4 bit packed pixel formats */ png_set_packswap(png_ptr); /* Turn on interlace handling if you are not using png_write_image() */ if (interlacing != 0) number_passes = png_set_interlace_handling(png_ptr); else number_passes = 1; /* The easiest way to write the image (you may have a different memory * layout, however, so choose what fits your needs best). You need to * use the first method if you aren't handling interlacing yourself. */ png_uint_32 k, height, width; /* In this example, "image" is a one-dimensional array of bytes */ png_byte image[height*width*bytes_per_pixel]; png_bytep row_pointers[height]; if (height > PNG_UINT_32_MAX/(sizeof (png_bytep))) png_error (png_ptr, "Image is too tall to process in memory"); /* Set up pointers into your "image" byte array */ for (k = 0; k < height; k++) row_pointers[k] = image + k*width*bytes_per_pixel; /* One of the following output methods is REQUIRED */ #ifdef entire /* Write out the entire image data in one call */ png_write_image(png_ptr, row_pointers); /* The other way to write the image - deal with interlacing */ #else no_entire /* Write out the image data by one or more scanlines */ /* The number of passes is either 1 for non-interlaced images, * or 7 for interlaced images. */ for (pass = 0; pass < number_passes; pass++) { /* Write a few rows at a time. */ png_write_rows(png_ptr, &row_pointers[first_row], number_of_rows); /* If you are only writing one row at a time, this works */ for (y = 0; y < height; y++) png_write_rows(png_ptr, &row_pointers[y], 1); } #endif no_entire /* Use only one output method */ /* You can write optional chunks like tEXt, zTXt, and tIME at the end * as well. Shouldn't be necessary in 1.2.0 and up as all the public * chunks are supported and you can use png_set_unknown_chunks() to * register unknown chunks into the info structure to be written out. */ /* It is REQUIRED to call this to finish writing the rest of the file */ png_write_end(png_ptr, info_ptr); #endif hilevel /* If you png_malloced a palette, free it here (don't free info_ptr->palette, * as recommended in versions 1.0.5m and earlier of this example; if * libpng mallocs info_ptr->palette, libpng will free it). If you * allocated it with malloc() instead of png_malloc(), use free() instead * of png_free(). */ png_free(png_ptr, palette); palette = NULL; /* Similarly, if you png_malloced any data that you passed in with * png_set_something(), such as a hist or trans array, free it here, * when you can be sure that libpng is through with it. */ png_free(png_ptr, trans); trans = NULL; /* Whenever you use png_free() it is a good idea to set the pointer to * NULL in case your application inadvertently tries to png_free() it * again. When png_free() sees a NULL it returns without action, thus * avoiding the double-free security problem. */ /* Clean up after the write, and free any memory allocated */ png_destroy_write_struct(&png_ptr, &info_ptr); /* Close the file */ fclose(fp); /* That's it */ return (OK); } #endif /* if 0 */
the_stack_data/1201717.c
/* * Copyright 2008 The Native Client Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <string.h> #include <unistd.h> size_t strnlen(const char* string, size_t max); size_t strnlen(const char* string, size_t max) { const char* end = (const char*)memchr(string, '\0', max); return end ? (size_t)(end - string) : max; }
the_stack_data/190767079.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2013-2017 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> int v; int main() { /* Don't let the test case run forever. */ alarm (60); for (;;) ; }
the_stack_data/22013896.c
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % V V M M SSSSS % % V V MM MM SS % % V V M M M SSS % % V V M M SS % % V M M SSSSS % % % % % % MagickCore VMS Utility Methods % % % % Software Design % % John Cristy % % October 1994 % % % % % % Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization % % dedicated to making software imaging solutions freely available. % % % % You may not use this file except in compliance with the License. You may % % obtain a copy of the License at % % % % http://www.imagemagick.org/script/license.php % % % % Unless required by applicable law or agreed to in writing, software % % distributed under the License is distributed on an "AS IS" BASIS, % % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % % See the License for the specific language governing permissions and % % limitations under the License. % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % The directory methods are strongly based on similar methods written % by Rich Salz. % */ #if defined(vms) /* Include declarations. */ #include "magick/studio.h" #include "magick/string_.h" #include "magick/memory_.h" #include "magick/vms.h" #if !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000)) /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % c l o s e d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % closedir() closes the named directory stream and frees the DIR structure. % % The format of the closedir method is: % % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ void closedir(DIR *directory) { if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); assert(directory != (DIR *) NULL); directory->pattern=DestroyString(directory->pattern); directory=DestroyString(directory); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % o p e n d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % opendir() opens the directory named by filename and associates a directory % stream with it. % % The format of the opendir method is: % % opendir(entry) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ DIR *opendir(char *name) { DIR *directory; /* Allocate memory for handle and the pattern. */ directory=(DIR *) AcquireMagickMemory(sizeof(DIR)); if (directory == (DIR *) NULL) { errno=ENOMEM; return((DIR *) NULL); } if (strcmp(".",name) == 0) name=""; directory->pattern=(char *) AcquireQuantumMemory(strlen(name)+sizeof("*.*")+ 1UL,sizeof(*directory->pattern)); if (directory->pattern == (char *) NULL) { directory=DestroyString(directory); errno=ENOMEM; return(NULL); } /* Initialize descriptor. */ (void) FormatMagickString(directory->pattern,MaxTextExtent,"%s*.*",name); directory->context=0; directory->pat.dsc$a_pointer=directory->pattern; directory->pat.dsc$w_length=strlen(directory->pattern); directory->pat.dsc$b_dtype=DSC$K_DTYPE_T; directory->pat.dsc$b_class=DSC$K_CLASS_S; return(directory); } /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % r e a d d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % readdir() returns a pointer to a structure representing the directory entry % at the current position in the directory stream to which entry refers. % % The format of the readdir % % readdir(entry) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ struct dirent *readdir(DIR *directory) { char buffer[sizeof(directory->entry.d_name)]; int status; register char *p; register int i; struct dsc$descriptor_s result; /* Initialize the result descriptor. */ result.dsc$a_pointer=buffer; result.dsc$w_length=sizeof(buffer)-2; result.dsc$b_dtype=DSC$K_DTYPE_T; result.dsc$b_class=DSC$K_CLASS_S; status=lib$find_file(&directory->pat,&result,&directory->context); if ((status == RMS$_NMF) || (directory->context == 0L)) return((struct dirent *) NULL); /* Lowercase all filenames. */ buffer[sizeof(buffer)-1]='\0'; for (p=buffer; *p; p++) if (isupper((unsigned char) *p)) *p=tolower(*p); /* Skip any directory component and just copy the name. */ p=buffer; while (isspace((unsigned char) *p) == 0) p++; *p='\0'; p=strchr(buffer,']'); if (p) (void) CopyMagickString(directory->entry.d_name,p+1,MaxTextExtent); else (void) CopyMagickString(directory->entry.d_name,buffer,MaxTextExtent); directory->entry.d_namlen=strlen(directory->entry.d_name); return(&directory->entry); } #endif /* !defined(_AXP_) && (!defined(__VMS_VER) || (__VMS_VER < 70000000)) */ /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % I s M a g i c k C o n f l i c t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % VMSIsMagickConflict() returns true if the image format conflicts with a % logical drive (.e.g. SYS$SCRATCH:). % % Contributed by Forrest Cahoon ([email protected]) % % The format of the VMSIsMagickConflict method is: % % MagickBooleanType VMSIsMagickConflict(const char *magick) % % A description of each parameter follows: % % o magick: Specifies the image format. % % */ MagickExport MagickBooleanType VMSIsMagickConflict(const char *magick) { ile3 item_list[2]; int device_class, status; struct dsc$descriptor_s device; assert(magick != (char *) NULL); device.dsc$w_length=strlen(magick); device.dsc$a_pointer=(char *) magick; device.dsc$b_class=DSC$K_CLASS_S; device.dsc$b_dtype=DSC$K_DTYPE_T; item_list[0].ile3$w_length=sizeof(device_class); item_list[0].ile3$w_code=DVI$_DEVCLASS; item_list[0].ile3$ps_bufaddr=&device_class; item_list[0].ile3$ps_retlen_addr=NULL; (void) ResetMagickMemory(&item_list[1],0,sizeof(item_list[1])); status=sys$getdviw(0,0,&device,&item_list,0,0,0,0); if ((status == SS$_NONLOCAL) || ((status & 0x01) && (device_class & (DC$_DISK | DC$_TAPE)))) return(MagickTrue); return(MagickFalse); } #endif /* defined(vms) */
the_stack_data/1238295.c
#include <stdio.h> #include <string.h> int main() { char c[1000]; fgets(c, sizeof c / sizeof c[0], stdin); int d = strlen(c); char a[d]; int j = 0; for (int i = d - 1; i >= 0; i--) { a[i] = c[j]; j++; } puts(a); return 0; } /** Error: * input ainiqusi * output isuqinia@ */
the_stack_data/225141951.c
// // Created by semyon on 12.05.2020. // // Написать функцию пользователя, позволяющую выполнять решение задачи табулирования для произвольной функции одного переменного. // Табулируемая функция передается через параметр табулирующей функции. // Результаты табулирования выводятся на экран монитора. #include <stdio.h> typedef double(*function)(double x); void tab(function f) { for (double i = -1000; i < 1000; i++) { printf("%lf \n", f(i)); } } double f(double x) { return x * 2; } double f2(double x) { return x * x; } int main() { tab(&f); tab(&f2); }
the_stack_data/128425.c
#include <errno.h> #include <sys/timeb.h> int _ftime(struct timeb *tp) { errno = ENOSYS; return -1; }
the_stack_data/20194.c
// Taken from https://github.com/cpluss/cpl-rpi/blob/c41eadc5bcf9655601d6b4cc12d91787edf21610/src/uart.c // The MIT License (MIT) // // Copyright (c) 2015 Sebastian Lund // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in // the Software without restriction, including without limitation the rights to // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of // the Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <stddef.h> #include <stdint.h> int32_t sum(int32_t, int32_t); static uint32_t MMIO_BASE; // The MMIO area base address, depends on board type static inline void mmio_init(int raspi) { switch (raspi) { case 2: case 3: MMIO_BASE = 0x3F000000; break; // for raspi2 & 3 case 4: MMIO_BASE = 0xFE000000; break; // for raspi4 default: MMIO_BASE = 0x20000000; break; // for raspi1, raspi zero etc. } } // Memory-Mapped I/O output static inline void mmio_write(uint32_t reg, uint32_t data) { *(volatile uint32_t*)(MMIO_BASE + reg) = data; } // Memory-Mapped I/O input static inline uint32_t mmio_read(uint32_t reg) { return *(volatile uint32_t*)(MMIO_BASE + reg); } // Loop <delay> times in a way that the compiler won't optimize away static inline void delay(int32_t count) { asm volatile("__delay_%=: subs %[count], %[count], #1; bne __delay_%=\n" : "=r"(count): [count]"0"(count) : "cc"); } enum { // The offsets for reach register. GPIO_BASE = 0x200000, // Controls actuation of pull up/down to ALL GPIO pins. GPPUD = (GPIO_BASE + 0x94), // Controls actuation of pull up/down for specific GPIO pin. GPPUDCLK0 = (GPIO_BASE + 0x98), // The base address for UART. UART0_BASE = (GPIO_BASE + 0x1000), // for raspi4 0xFE201000, raspi2 & 3 0x3F201000, and 0x20201000 for raspi1 // The offsets for reach register for the UART. UART0_DR = (UART0_BASE + 0x00), UART0_RSRECR = (UART0_BASE + 0x04), UART0_FR = (UART0_BASE + 0x18), UART0_ILPR = (UART0_BASE + 0x20), UART0_IBRD = (UART0_BASE + 0x24), UART0_FBRD = (UART0_BASE + 0x28), UART0_LCRH = (UART0_BASE + 0x2C), UART0_CR = (UART0_BASE + 0x30), UART0_IFLS = (UART0_BASE + 0x34), UART0_IMSC = (UART0_BASE + 0x38), UART0_RIS = (UART0_BASE + 0x3C), UART0_MIS = (UART0_BASE + 0x40), UART0_ICR = (UART0_BASE + 0x44), UART0_DMACR = (UART0_BASE + 0x48), UART0_ITCR = (UART0_BASE + 0x80), UART0_ITIP = (UART0_BASE + 0x84), UART0_ITOP = (UART0_BASE + 0x88), UART0_TDR = (UART0_BASE + 0x8C), // The offsets for Mailbox registers MBOX_BASE = 0xB880, MBOX_READ = (MBOX_BASE + 0x00), MBOX_STATUS = (MBOX_BASE + 0x18), MBOX_WRITE = (MBOX_BASE + 0x20) }; // A Mailbox message with set clock rate of PL011 to 3MHz tag volatile unsigned int __attribute__((aligned(16))) mbox[9] = { 9*4, 0, 0x38002, 12, 8, 2, 3000000, 0 ,0 }; void uart_init(int raspi) { mmio_init(raspi); // Disable UART0. mmio_write(UART0_CR, 0x00000000); // Setup the GPIO pin 14 && 15. // Disable pull up/down for all GPIO pins & delay for 150 cycles. mmio_write(GPPUD, 0x00000000); delay(150); // Disable pull up/down for pin 14,15 & delay for 150 cycles. mmio_write(GPPUDCLK0, (1 << 14) | (1 << 15)); delay(150); // Write 0 to GPPUDCLK0 to make it take effect. mmio_write(GPPUDCLK0, 0x00000000); // Clear pending interrupts. mmio_write(UART0_ICR, 0x7FF); // Set integer & fractional part of baud rate. // Divider = UART_CLOCK/(16 * Baud) // Fraction part register = (Fractional part * 64) + 0.5 // Baud = 115200. // For Raspi3 and 4 the UART_CLOCK is system-clock dependent by default. // Set it to 3Mhz so that we can consistently set the baud rate if (raspi >= 3) { // UART_CLOCK = 30000000; unsigned int r = (((unsigned int)(&mbox) & ~0xF) | 8); // wait until we can talk to the VC while ( mmio_read(MBOX_STATUS) & 0x80000000 ) { } // send our message to property channel and wait for the response mmio_write(MBOX_WRITE, r); while ( (mmio_read(MBOX_STATUS) & 0x40000000) || mmio_read(MBOX_READ) != r ) { } } // Divider = 3000000 / (16 * 115200) = 1.627 = ~1. mmio_write(UART0_IBRD, 1); // Fractional part register = (.627 * 64) + 0.5 = 40.6 = ~40. mmio_write(UART0_FBRD, 40); // Enable FIFO & 8 bit data transmission (1 stop bit, no parity). mmio_write(UART0_LCRH, (1 << 4) | (1 << 5) | (1 << 6)); // Mask all interrupts. mmio_write(UART0_IMSC, (1 << 1) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10)); // Enable UART0, receive & transfer part of UART. mmio_write(UART0_CR, (1 << 0) | (1 << 8) | (1 << 9)); } void uart_putc(unsigned char c) { // Wait for UART to become ready to transmit. while ( mmio_read(UART0_FR) & (1 << 5) ) { } mmio_write(UART0_DR, c); } unsigned char uart_getc() { // Wait for UART to have received something. while ( mmio_read(UART0_FR) & (1 << 4) ) { } return mmio_read(UART0_DR); } void uart_puts(const char* str) { for (size_t i = 0; str[i] != '\0'; i ++) uart_putc((unsigned char)str[i]); } void iprint(int n) { if( n > 9 ) { int a = n / 10; n -= 10 * a; iprint(a); } uart_putc('0'+n); } #if defined(__cplusplus) extern "C" /* Use C linkage for kernel_main. */ #endif #ifdef AARCH64 // arguments for AArch64 void kernel_main(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3) #else // arguments for AArch32 void kernel_main(uint32_t r0, uint32_t r1, uint32_t atags) #endif { // initialize UART for Raspi2 uart_init(2); iprint(sum(40, 2)); uart_puts("\r\n"); uart_puts("Hello, kernel World!\r\n"); while (1) uart_putc(uart_getc()); }
the_stack_data/600468.c
#include <stdlib.h> unsigned gcd(unsigned a, unsigned b) { if (a < 0) a = abs(a); while (a != 0 && b != 0) { if (a > b) a -= b; else b -= a; } return (a != 0 ? a : b); }
the_stack_data/7951569.c
#include <stdio.h> #include <stdlib.h> int main(){ int P[150],i,contP=0; int C[220],n,contC=0; for(i=0;i<150;i++){ printf("P[%d]:",i); scanf("%d",&P[i]); contP+=1; if (P[i]==9999){ contP-=1; break; } } for(i=0;i<220;i++){ printf("C[%d]:",i); scanf("%d",&C[i]); contC+=1; if (C[i]==9999){ contC-=1; break; } } for(i=0;i<contP;i++){ for(n=0;n<contC;n++){ if(P[i]==C[n]){ printf("%d ",P[i]); } } } }
the_stack_data/1098581.c
#include "stdio.h" int main(void) { int n = 5; if (n == 1 - 10) { printf("%s\n", "n is between 1 and 10"); } return 0; }
the_stack_data/68887217.c
//There's a problem with the merger when a parameter overlaps with a static local. int fun1(int n) { return n; } int qux() { static int n = 3; return n; } int fun2() { int n; //This local doesn't seem to cause any problems. return n; } int main() { return 0; }
the_stack_data/51699125.c
# 1 "../C_SRC/histogram.c.tmp.c" # 1 "<built-in>" # 1 "<command-line>" # 31 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 32 "<command-line>" 2 # 1 "../C_SRC/histogram.c.tmp.c" # 1 "/usr/include/stdio.h" 1 3 4 # 27 "/usr/include/stdio.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4 # 33 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 3 4 # 1 "/usr/include/features.h" 1 3 4 # 424 "/usr/include/features.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 1 3 4 # 427 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 # 428 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/long-double.h" 1 3 4 # 429 "/usr/include/x86_64-linux-gnu/sys/cdefs.h" 2 3 4 # 425 "/usr/include/features.h" 2 3 4 # 448 "/usr/include/features.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 1 3 4 # 10 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/gnu/stubs-64.h" 1 3 4 # 11 "/usr/include/x86_64-linux-gnu/gnu/stubs.h" 2 3 4 # 449 "/usr/include/features.h" 2 3 4 # 34 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 2 3 4 # 28 "/usr/include/stdio.h" 2 3 4 # 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4 # 216 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 3 4 # 216 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 3 4 typedef long unsigned int size_t; # 34 "/usr/include/stdio.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types.h" 1 3 4 # 27 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 # 28 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 typedef unsigned char __u_char; typedef unsigned short int __u_short; typedef unsigned int __u_int; typedef unsigned long int __u_long; typedef signed char __int8_t; typedef unsigned char __uint8_t; typedef signed short int __int16_t; typedef unsigned short int __uint16_t; typedef signed int __int32_t; typedef unsigned int __uint32_t; typedef signed long int __int64_t; typedef unsigned long int __uint64_t; typedef long int __quad_t; typedef unsigned long int __u_quad_t; typedef long int __intmax_t; typedef unsigned long int __uintmax_t; # 130 "/usr/include/x86_64-linux-gnu/bits/types.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/typesizes.h" 1 3 4 # 131 "/usr/include/x86_64-linux-gnu/bits/types.h" 2 3 4 typedef unsigned long int __dev_t; typedef unsigned int __uid_t; typedef unsigned int __gid_t; typedef unsigned long int __ino_t; typedef unsigned long int __ino64_t; typedef unsigned int __mode_t; typedef unsigned long int __nlink_t; typedef long int __off_t; typedef long int __off64_t; typedef int __pid_t; typedef struct { int __val[2]; } __fsid_t; typedef long int __clock_t; typedef unsigned long int __rlim_t; typedef unsigned long int __rlim64_t; typedef unsigned int __id_t; typedef long int __time_t; typedef unsigned int __useconds_t; typedef long int __suseconds_t; typedef int __daddr_t; typedef int __key_t; typedef int __clockid_t; typedef void * __timer_t; typedef long int __blksize_t; typedef long int __blkcnt_t; typedef long int __blkcnt64_t; typedef unsigned long int __fsblkcnt_t; typedef unsigned long int __fsblkcnt64_t; typedef unsigned long int __fsfilcnt_t; typedef unsigned long int __fsfilcnt64_t; typedef long int __fsword_t; typedef long int __ssize_t; typedef long int __syscall_slong_t; typedef unsigned long int __syscall_ulong_t; typedef __off64_t __loff_t; typedef char *__caddr_t; typedef long int __intptr_t; typedef unsigned int __socklen_t; typedef int __sig_atomic_t; # 36 "/usr/include/stdio.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/__FILE.h" 1 3 4 struct _IO_FILE; typedef struct _IO_FILE __FILE; # 37 "/usr/include/stdio.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/FILE.h" 1 3 4 struct _IO_FILE; typedef struct _IO_FILE FILE; # 38 "/usr/include/stdio.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/libio.h" 1 3 4 # 35 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 1 3 4 # 19 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 3 4 # 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4 # 20 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h" 1 3 4 # 13 "/usr/include/x86_64-linux-gnu/bits/types/__mbstate_t.h" 3 4 typedef struct { int __count; union { unsigned int __wch; char __wchb[4]; } __value; } __mbstate_t; # 22 "/usr/include/x86_64-linux-gnu/bits/_G_config.h" 2 3 4 typedef struct { __off_t __pos; __mbstate_t __state; } _G_fpos_t; typedef struct { __off64_t __pos; __mbstate_t __state; } _G_fpos64_t; # 36 "/usr/include/x86_64-linux-gnu/bits/libio.h" 2 3 4 # 53 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 # 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h" 1 3 4 # 40 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stdarg.h" 3 4 typedef __builtin_va_list __gnuc_va_list; # 54 "/usr/include/x86_64-linux-gnu/bits/libio.h" 2 3 4 # 149 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 struct _IO_jump_t; struct _IO_FILE; typedef void _IO_lock_t; struct _IO_marker { struct _IO_marker *_next; struct _IO_FILE *_sbuf; int _pos; # 177 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 }; enum __codecvt_result { __codecvt_ok, __codecvt_partial, __codecvt_error, __codecvt_noconv }; # 245 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 struct _IO_FILE { int _flags; char* _IO_read_ptr; char* _IO_read_end; char* _IO_read_base; char* _IO_write_base; char* _IO_write_ptr; char* _IO_write_end; char* _IO_buf_base; char* _IO_buf_end; char *_IO_save_base; char *_IO_backup_base; char *_IO_save_end; struct _IO_marker *_markers; struct _IO_FILE *_chain; int _fileno; int _flags2; __off_t _old_offset; unsigned short _cur_column; signed char _vtable_offset; char _shortbuf[1]; _IO_lock_t *_lock; # 293 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 __off64_t _offset; void *__pad1; void *__pad2; void *__pad3; void *__pad4; size_t __pad5; int _mode; char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; }; typedef struct _IO_FILE _IO_FILE; struct _IO_FILE_plus; extern struct _IO_FILE_plus _IO_2_1_stdin_; extern struct _IO_FILE_plus _IO_2_1_stdout_; extern struct _IO_FILE_plus _IO_2_1_stderr_; # 337 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes); typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf, size_t __n); typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w); typedef int __io_close_fn (void *__cookie); # 389 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 extern int __underflow (_IO_FILE *); extern int __uflow (_IO_FILE *); extern int __overflow (_IO_FILE *, int); # 433 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 extern int _IO_getc (_IO_FILE *__fp); extern int _IO_putc (int __c, _IO_FILE *__fp); extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__)); extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__)); extern int _IO_peekc_locked (_IO_FILE *__fp); extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__)); extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__)); extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__)); # 462 "/usr/include/x86_64-linux-gnu/bits/libio.h" 3 4 extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, __gnuc_va_list, int *__restrict); extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, __gnuc_va_list); extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t); extern size_t _IO_sgetn (_IO_FILE *, void *, size_t); extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int); extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int); extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__)); # 42 "/usr/include/stdio.h" 2 3 4 typedef __gnuc_va_list va_list; # 57 "/usr/include/stdio.h" 3 4 typedef __off_t off_t; # 71 "/usr/include/stdio.h" 3 4 typedef __ssize_t ssize_t; typedef _G_fpos_t fpos_t; # 131 "/usr/include/stdio.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/stdio_lim.h" 1 3 4 # 132 "/usr/include/stdio.h" 2 3 4 extern struct _IO_FILE *stdin; extern struct _IO_FILE *stdout; extern struct _IO_FILE *stderr; extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__)); extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__)); extern int renameat (int __oldfd, const char *__old, int __newfd, const char *__new) __attribute__ ((__nothrow__ , __leaf__)); extern FILE *tmpfile (void) ; # 173 "/usr/include/stdio.h" 3 4 extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ; extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ; # 190 "/usr/include/stdio.h" 3 4 extern char *tempnam (const char *__dir, const char *__pfx) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; extern int fclose (FILE *__stream); extern int fflush (FILE *__stream); # 213 "/usr/include/stdio.h" 3 4 extern int fflush_unlocked (FILE *__stream); # 232 "/usr/include/stdio.h" 3 4 extern FILE *fopen (const char *__restrict __filename, const char *__restrict __modes) ; extern FILE *freopen (const char *__restrict __filename, const char *__restrict __modes, FILE *__restrict __stream) ; # 265 "/usr/include/stdio.h" 3 4 extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ; # 278 "/usr/include/stdio.h" 3 4 extern FILE *fmemopen (void *__s, size_t __len, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ; extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ; extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)); extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, size_t __size) __attribute__ ((__nothrow__ , __leaf__)); extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); extern int fprintf (FILE *__restrict __stream, const char *__restrict __format, ...); extern int printf (const char *__restrict __format, ...); extern int sprintf (char *__restrict __s, const char *__restrict __format, ...) __attribute__ ((__nothrow__)); extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg); extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); extern int vsprintf (char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__nothrow__)); extern int snprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...) __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4))); extern int vsnprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0))); # 365 "/usr/include/stdio.h" 3 4 extern int vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __arg) __attribute__ ((__format__ (__printf__, 2, 0))); extern int dprintf (int __fd, const char *__restrict __fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) ; extern int scanf (const char *__restrict __format, ...) ; extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__)); # 395 "/usr/include/stdio.h" 3 4 extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf") ; extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf") ; extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __asm__ ("" "__isoc99_sscanf") __attribute__ ((__nothrow__ , __leaf__)) ; # 420 "/usr/include/stdio.h" 3 4 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))) ; extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 1, 0))) ; extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0))); # 443 "/usr/include/stdio.h" 3 4 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf") __attribute__ ((__format__ (__scanf__, 2, 0))) ; extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf") __attribute__ ((__format__ (__scanf__, 1, 0))) ; extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0))); # 477 "/usr/include/stdio.h" 3 4 extern int fgetc (FILE *__stream); extern int getc (FILE *__stream); extern int getchar (void); # 495 "/usr/include/stdio.h" 3 4 extern int getc_unlocked (FILE *__stream); extern int getchar_unlocked (void); # 506 "/usr/include/stdio.h" 3 4 extern int fgetc_unlocked (FILE *__stream); # 517 "/usr/include/stdio.h" 3 4 extern int fputc (int __c, FILE *__stream); extern int putc (int __c, FILE *__stream); extern int putchar (int __c); # 537 "/usr/include/stdio.h" 3 4 extern int fputc_unlocked (int __c, FILE *__stream); extern int putc_unlocked (int __c, FILE *__stream); extern int putchar_unlocked (int __c); extern int getw (FILE *__stream); extern int putw (int __w, FILE *__stream); extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) ; # 603 "/usr/include/stdio.h" 3 4 extern __ssize_t __getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, FILE *__restrict __stream) ; extern __ssize_t getdelim (char **__restrict __lineptr, size_t *__restrict __n, int __delimiter, FILE *__restrict __stream) ; extern __ssize_t getline (char **__restrict __lineptr, size_t *__restrict __n, FILE *__restrict __stream) ; extern int fputs (const char *__restrict __s, FILE *__restrict __stream); extern int puts (const char *__s); extern int ungetc (int __c, FILE *__stream); extern size_t fread (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) ; extern size_t fwrite (const void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __s); # 673 "/usr/include/stdio.h" 3 4 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) ; extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream); extern int fseek (FILE *__stream, long int __off, int __whence); extern long int ftell (FILE *__stream) ; extern void rewind (FILE *__stream); # 707 "/usr/include/stdio.h" 3 4 extern int fseeko (FILE *__stream, __off_t __off, int __whence); extern __off_t ftello (FILE *__stream) ; # 731 "/usr/include/stdio.h" 3 4 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); extern int fsetpos (FILE *__stream, const fpos_t *__pos); # 757 "/usr/include/stdio.h" 3 4 extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; extern void perror (const char *__s); # 1 "/usr/include/x86_64-linux-gnu/bits/sys_errlist.h" 1 3 4 # 26 "/usr/include/x86_64-linux-gnu/bits/sys_errlist.h" 3 4 extern int sys_nerr; extern const char *const sys_errlist[]; # 782 "/usr/include/stdio.h" 2 3 4 extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; # 800 "/usr/include/stdio.h" 3 4 extern FILE *popen (const char *__command, const char *__modes) ; extern int pclose (FILE *__stream); extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__)); # 840 "/usr/include/stdio.h" 3 4 extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); # 868 "/usr/include/stdio.h" 3 4 # 2 "../C_SRC/histogram.c.tmp.c" 2 # 1 "../C_SRC/histogram.h" 1 # 1 "../C_SRC/histogram.h" typedef int in_int_t; typedef int in_int_t; typedef int inout_int_t; void histogram( in_int_t x[100], in_int_t w[100], inout_int_t hist[100]); # 3 "../C_SRC/histogram.c.tmp.c" 2 # 1 "/usr/include/stdlib.h" 1 3 4 # 25 "/usr/include/stdlib.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/libc-header-start.h" 1 3 4 # 26 "/usr/include/stdlib.h" 2 3 4 # 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4 # 328 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 3 4 # 328 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 3 4 typedef int wchar_t; # 32 "/usr/include/stdlib.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/waitflags.h" 1 3 4 # 52 "/usr/include/x86_64-linux-gnu/bits/waitflags.h" 3 4 typedef enum { P_ALL, P_PID, P_PGID } idtype_t; # 40 "/usr/include/stdlib.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/waitstatus.h" 1 3 4 # 41 "/usr/include/stdlib.h" 2 3 4 # 55 "/usr/include/stdlib.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/floatn.h" 1 3 4 # 120 "/usr/include/x86_64-linux-gnu/bits/floatn.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/floatn-common.h" 1 3 4 # 24 "/usr/include/x86_64-linux-gnu/bits/floatn-common.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/long-double.h" 1 3 4 # 25 "/usr/include/x86_64-linux-gnu/bits/floatn-common.h" 2 3 4 # 121 "/usr/include/x86_64-linux-gnu/bits/floatn.h" 2 3 4 # 56 "/usr/include/stdlib.h" 2 3 4 typedef struct { int quot; int rem; } div_t; typedef struct { long int quot; long int rem; } ldiv_t; __extension__ typedef struct { long long int quot; long long int rem; } lldiv_t; # 97 "/usr/include/stdlib.h" 3 4 extern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__ , __leaf__)) ; extern double atof (const char *__nptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; extern int atoi (const char *__nptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; extern long int atol (const char *__nptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; __extension__ extern long long int atoll (const char *__nptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; extern double strtod (const char *__restrict __nptr, char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern float strtof (const char *__restrict __nptr, char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern long double strtold (const char *__restrict __nptr, char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); # 176 "/usr/include/stdlib.h" 3 4 extern long int strtol (const char *__restrict __nptr, char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern unsigned long int strtoul (const char *__restrict __nptr, char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); __extension__ extern long long int strtoq (const char *__restrict __nptr, char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); __extension__ extern unsigned long long int strtouq (const char *__restrict __nptr, char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); __extension__ extern long long int strtoll (const char *__restrict __nptr, char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); __extension__ extern unsigned long long int strtoull (const char *__restrict __nptr, char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); # 385 "/usr/include/stdlib.h" 3 4 extern char *l64a (long int __n) __attribute__ ((__nothrow__ , __leaf__)) ; extern long int a64l (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; # 1 "/usr/include/x86_64-linux-gnu/sys/types.h" 1 3 4 # 27 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 typedef __u_char u_char; typedef __u_short u_short; typedef __u_int u_int; typedef __u_long u_long; typedef __quad_t quad_t; typedef __u_quad_t u_quad_t; typedef __fsid_t fsid_t; typedef __loff_t loff_t; typedef __ino_t ino_t; # 60 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 typedef __dev_t dev_t; typedef __gid_t gid_t; typedef __mode_t mode_t; typedef __nlink_t nlink_t; typedef __uid_t uid_t; # 98 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 typedef __pid_t pid_t; typedef __id_t id_t; # 115 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 typedef __daddr_t daddr_t; typedef __caddr_t caddr_t; typedef __key_t key_t; # 1 "/usr/include/x86_64-linux-gnu/bits/types/clock_t.h" 1 3 4 typedef __clock_t clock_t; # 128 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/clockid_t.h" 1 3 4 typedef __clockid_t clockid_t; # 130 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/time_t.h" 1 3 4 typedef __time_t time_t; # 131 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/timer_t.h" 1 3 4 typedef __timer_t timer_t; # 132 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 145 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 # 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4 # 146 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 typedef unsigned long int ulong; typedef unsigned short int ushort; typedef unsigned int uint; # 1 "/usr/include/x86_64-linux-gnu/bits/stdint-intn.h" 1 3 4 # 24 "/usr/include/x86_64-linux-gnu/bits/stdint-intn.h" 3 4 typedef __int8_t int8_t; typedef __int16_t int16_t; typedef __int32_t int32_t; typedef __int64_t int64_t; # 157 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 178 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__))); typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__))); typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__))); typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__))); typedef int register_t __attribute__ ((__mode__ (__word__))); # 194 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 # 1 "/usr/include/endian.h" 1 3 4 # 36 "/usr/include/endian.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/endian.h" 1 3 4 # 37 "/usr/include/endian.h" 2 3 4 # 60 "/usr/include/endian.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 1 3 4 # 28 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 # 29 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/byteswap-16.h" 1 3 4 # 36 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 2 3 4 # 44 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4 static __inline unsigned int __bswap_32 (unsigned int __bsx) { return __builtin_bswap32 (__bsx); } # 108 "/usr/include/x86_64-linux-gnu/bits/byteswap.h" 3 4 static __inline __uint64_t __bswap_64 (__uint64_t __bsx) { return __builtin_bswap64 (__bsx); } # 61 "/usr/include/endian.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/uintn-identity.h" 1 3 4 # 32 "/usr/include/x86_64-linux-gnu/bits/uintn-identity.h" 3 4 static __inline __uint16_t __uint16_identity (__uint16_t __x) { return __x; } static __inline __uint32_t __uint32_identity (__uint32_t __x) { return __x; } static __inline __uint64_t __uint64_identity (__uint64_t __x) { return __x; } # 62 "/usr/include/endian.h" 2 3 4 # 195 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/sys/select.h" 1 3 4 # 30 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/select.h" 1 3 4 # 22 "/usr/include/x86_64-linux-gnu/bits/select.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 # 23 "/usr/include/x86_64-linux-gnu/bits/select.h" 2 3 4 # 31 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h" 1 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/__sigset_t.h" 1 3 4 typedef struct { unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))]; } __sigset_t; # 5 "/usr/include/x86_64-linux-gnu/bits/types/sigset_t.h" 2 3 4 typedef __sigset_t sigset_t; # 34 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_timeval.h" 1 3 4 struct timeval { __time_t tv_sec; __suseconds_t tv_usec; }; # 38 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/types/struct_timespec.h" 1 3 4 struct timespec { __time_t tv_sec; __syscall_slong_t tv_nsec; }; # 40 "/usr/include/x86_64-linux-gnu/sys/select.h" 2 3 4 typedef __suseconds_t suseconds_t; typedef long int __fd_mask; # 59 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4 typedef struct { __fd_mask __fds_bits[1024 / (8 * (int) sizeof (__fd_mask))]; } fd_set; typedef __fd_mask fd_mask; # 91 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4 # 101 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4 extern int select (int __nfds, fd_set *__restrict __readfds, fd_set *__restrict __writefds, fd_set *__restrict __exceptfds, struct timeval *__restrict __timeout); # 113 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4 extern int pselect (int __nfds, fd_set *__restrict __readfds, fd_set *__restrict __writefds, fd_set *__restrict __exceptfds, const struct timespec *__restrict __timeout, const __sigset_t *__restrict __sigmask); # 126 "/usr/include/x86_64-linux-gnu/sys/select.h" 3 4 # 198 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 1 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 1 3 4 # 41 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/sysmacros.h" 1 3 4 # 42 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 2 3 4 # 71 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3 4 extern unsigned int gnu_dev_major (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern unsigned int gnu_dev_minor (__dev_t __dev) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern __dev_t gnu_dev_makedev (unsigned int __major, unsigned int __minor) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); # 85 "/usr/include/x86_64-linux-gnu/sys/sysmacros.h" 3 4 # 206 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 typedef __blksize_t blksize_t; typedef __blkcnt_t blkcnt_t; typedef __fsblkcnt_t fsblkcnt_t; typedef __fsfilcnt_t fsfilcnt_t; # 254 "/usr/include/x86_64-linux-gnu/sys/types.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 1 3 4 # 23 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 1 3 4 # 77 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 1 3 4 # 21 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/wordsize.h" 1 3 4 # 22 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 2 3 4 # 65 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 3 4 struct __pthread_rwlock_arch_t { unsigned int __readers; unsigned int __writers; unsigned int __wrphase_futex; unsigned int __writers_futex; unsigned int __pad3; unsigned int __pad4; int __cur_writer; int __shared; signed char __rwelision; unsigned char __pad1[7]; unsigned long int __pad2; unsigned int __flags; # 99 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes-arch.h" 3 4 }; # 78 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 2 3 4 typedef struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __pthread_list_t; # 118 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 3 4 struct __pthread_mutex_s { int __lock ; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; __pthread_list_t __list; # 145 "/usr/include/x86_64-linux-gnu/bits/thread-shared-types.h" 3 4 }; struct __pthread_cond_s { __extension__ union { __extension__ unsigned long long int __wseq; struct { unsigned int __low; unsigned int __high; } __wseq32; }; __extension__ union { __extension__ unsigned long long int __g1_start; struct { unsigned int __low; unsigned int __high; } __g1_start32; }; unsigned int __g_refs[2] ; unsigned int __g_size[2]; unsigned int __g1_orig_size; unsigned int __wrefs; unsigned int __g_signals[2]; }; # 24 "/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h" 2 3 4 typedef unsigned long int pthread_t; typedef union { char __size[4]; int __align; } pthread_mutexattr_t; typedef union { char __size[4]; int __align; } pthread_condattr_t; typedef unsigned int pthread_key_t; typedef int pthread_once_t; union pthread_attr_t { char __size[56]; long int __align; }; typedef union pthread_attr_t pthread_attr_t; typedef union { struct __pthread_mutex_s __data; char __size[40]; long int __align; } pthread_mutex_t; typedef union { struct __pthread_cond_s __data; char __size[48]; __extension__ long long int __align; } pthread_cond_t; typedef union { struct __pthread_rwlock_arch_t __data; char __size[56]; long int __align; } pthread_rwlock_t; typedef union { char __size[8]; long int __align; } pthread_rwlockattr_t; typedef volatile int pthread_spinlock_t; typedef union { char __size[32]; long int __align; } pthread_barrier_t; typedef union { char __size[4]; int __align; } pthread_barrierattr_t; # 255 "/usr/include/x86_64-linux-gnu/sys/types.h" 2 3 4 # 395 "/usr/include/stdlib.h" 2 3 4 extern long int random (void) __attribute__ ((__nothrow__ , __leaf__)); extern void srandom (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__)); extern char *initstate (unsigned int __seed, char *__statebuf, size_t __statelen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); extern char *setstate (char *__statebuf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); struct random_data { int32_t *fptr; int32_t *rptr; int32_t *state; int rand_type; int rand_deg; int rand_sep; int32_t *end_ptr; }; extern int random_r (struct random_data *__restrict __buf, int32_t *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int srandom_r (unsigned int __seed, struct random_data *__buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); extern int initstate_r (unsigned int __seed, char *__restrict __statebuf, size_t __statelen, struct random_data *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4))); extern int setstate_r (char *__restrict __statebuf, struct random_data *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int rand (void) __attribute__ ((__nothrow__ , __leaf__)); extern void srand (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__)); extern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__ , __leaf__)); extern double drand48 (void) __attribute__ ((__nothrow__ , __leaf__)); extern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern long int lrand48 (void) __attribute__ ((__nothrow__ , __leaf__)); extern long int nrand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern long int mrand48 (void) __attribute__ ((__nothrow__ , __leaf__)); extern long int jrand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern void srand48 (long int __seedval) __attribute__ ((__nothrow__ , __leaf__)); extern unsigned short int *seed48 (unsigned short int __seed16v[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); struct drand48_data { unsigned short int __x[3]; unsigned short int __old_x[3]; unsigned short int __c; unsigned short int __init; __extension__ unsigned long long int __a; }; extern int drand48_r (struct drand48_data *__restrict __buffer, double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int erand48_r (unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int lrand48_r (struct drand48_data *__restrict __buffer, long int *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int nrand48_r (unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int mrand48_r (struct drand48_data *__restrict __buffer, long int *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int jrand48_r (unsigned short int __xsubi[3], struct drand48_data *__restrict __buffer, long int *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int srand48_r (long int __seedval, struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); extern int seed48_r (unsigned short int __seed16v[3], struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern int lcong48_r (unsigned short int __param[7], struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; extern void *calloc (size_t __nmemb, size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; extern void *realloc (void *__ptr, size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)); # 563 "/usr/include/stdlib.h" 3 4 extern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__)); # 1 "/usr/include/alloca.h" 1 3 4 # 24 "/usr/include/alloca.h" 3 4 # 1 "/usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h" 1 3 4 # 25 "/usr/include/alloca.h" 2 3 4 extern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__)); # 567 "/usr/include/stdlib.h" 2 3 4 extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; extern void *aligned_alloc (size_t __alignment, size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) ; extern void abort (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); extern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern int at_quick_exit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); extern void quick_exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); extern void _Exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); extern char *getenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; # 644 "/usr/include/stdlib.h" 3 4 extern int putenv (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern int setenv (const char *__name, const char *__value, int __replace) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); extern int unsetenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); extern int clearenv (void) __attribute__ ((__nothrow__ , __leaf__)); # 672 "/usr/include/stdlib.h" 3 4 extern char *mktemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); # 685 "/usr/include/stdlib.h" 3 4 extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ; # 707 "/usr/include/stdlib.h" 3 4 extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ; # 728 "/usr/include/stdlib.h" 3 4 extern char *mkdtemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; # 781 "/usr/include/stdlib.h" 3 4 extern int system (const char *__command) ; # 797 "/usr/include/stdlib.h" 3 4 extern char *realpath (const char *__restrict __name, char *__restrict __resolved) __attribute__ ((__nothrow__ , __leaf__)) ; typedef int (*__compar_fn_t) (const void *, const void *); # 817 "/usr/include/stdlib.h" 3 4 extern void *bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 2, 5))) ; extern void qsort (void *__base, size_t __nmemb, size_t __size, __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4))); # 837 "/usr/include/stdlib.h" 3 4 extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; extern long int labs (long int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; __extension__ extern long long int llabs (long long int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; extern div_t div (int __numer, int __denom) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; extern ldiv_t ldiv (long int __numer, long int __denom) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; __extension__ extern lldiv_t lldiv (long long int __numer, long long int __denom) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; # 869 "/usr/include/stdlib.h" 3 4 extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; extern char *gcvt (double __value, int __ndigit, char *__buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ; extern char *qecvt (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; extern char *qfcvt (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; extern char *qgcvt (long double __value, int __ndigit, char *__buf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ; extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); extern int qecvt_r (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); extern int qfcvt_r (long double __value, int __ndigit, int *__restrict __decpt, int *__restrict __sign, char *__restrict __buf, size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); extern int mblen (const char *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); extern int mbtowc (wchar_t *__restrict __pwc, const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); extern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__ , __leaf__)); extern size_t mbstowcs (wchar_t *__restrict __pwcs, const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); extern size_t wcstombs (char *__restrict __s, const wchar_t *__restrict __pwcs, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); extern int rpmatch (const char *__response) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; # 954 "/usr/include/stdlib.h" 3 4 extern int getsubopt (char **__restrict __optionp, char *const *__restrict __tokens, char **__restrict __valuep) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3))) ; # 1006 "/usr/include/stdlib.h" 3 4 extern int getloadavg (double __loadavg[], int __nelem) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); # 1016 "/usr/include/stdlib.h" 3 4 # 1 "/usr/include/x86_64-linux-gnu/bits/stdlib-float.h" 1 3 4 # 1017 "/usr/include/stdlib.h" 2 3 4 # 1026 "/usr/include/stdlib.h" 3 4 # 10 "../C_SRC/histogram.c.tmp.c" 2 # 1 "../C_SRC/histogram.h" 1 # 1 "../C_SRC/histogram.h" typedef int in_int_t; typedef int in_int_t; typedef int inout_int_t; void histogram( in_int_t x[100], in_int_t w[100], inout_int_t hist[100]); # 11 "../C_SRC/histogram.c.tmp.c" 2 int hlsv_transaction_id = -1; void histogram( in_int_t x[100], in_int_t w[100], inout_int_t hist[100]) { FILE * hlsv_if_x; FILE * hlsv_if_w; FILE * hlsv_if_hist; FILE * hlsv_of_hist; int hlsv_i = 0; int hlsv_i0 = 0; hlsv_transaction_id++; hlsv_if_x = fopen("../INPUT_VECTORS/input_x.dat", "a"); fprintf(hlsv_if_x, "[[transaction]] %d\n", hlsv_transaction_id); for(hlsv_i0 = 0; hlsv_i0 < 100; hlsv_i0++){ fprintf(hlsv_if_x, "0x%08llx\n", (long long)x[hlsv_i0]); } fprintf(hlsv_if_x, "[[/transaction]]\n"); fclose(hlsv_if_x); hlsv_if_w = fopen("../INPUT_VECTORS/input_w.dat", "a"); fprintf(hlsv_if_w, "[[transaction]] %d\n", hlsv_transaction_id); for(hlsv_i0 = 0; hlsv_i0 < 100; hlsv_i0++){ fprintf(hlsv_if_w, "0x%08llx\n", (long long)w[hlsv_i0]); } fprintf(hlsv_if_w, "[[/transaction]]\n"); fclose(hlsv_if_w); hlsv_if_hist = fopen("../INPUT_VECTORS/input_hist.dat", "a"); fprintf(hlsv_if_hist, "[[transaction]] %d\n", hlsv_transaction_id); for(hlsv_i0 = 0; hlsv_i0 < 100; hlsv_i0++){ fprintf(hlsv_if_hist, "0x%08llx\n", (long long)hist[hlsv_i0]); } fprintf(hlsv_if_hist, "[[/transaction]]\n"); fclose(hlsv_if_hist); for (int i=0; i<100; i++) { hist[x[i]] = hist[x[i]] * w[i]; } { hlsv_of_hist = fopen("../C_OUT/output_hist.dat", "a"); fprintf(hlsv_of_hist, "[[transaction]] %d\n", hlsv_transaction_id); for(hlsv_i0 = 0; hlsv_i0 < 100; hlsv_i0++){ fprintf(hlsv_of_hist, "0x%08llx\n", (long long)hist[hlsv_i0]); } fprintf(hlsv_of_hist, "[[/transaction]]\n"); fclose(hlsv_of_hist); return; } }
the_stack_data/1262154.c
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <math.h> #include <sys/mman.h> int main(int argc, char *argv[]) { int fd, i; volatile void *cfg, *sts; volatile uint32_t *wr, *rd; volatile uint8_t *rst; volatile uint32_t *freq; uint32_t buffer; int16_t value; if((fd = open("/dev/mem", O_RDWR)) < 0) { fprintf(stderr, "Cannot open /dev/mem.\n"); return EXIT_FAILURE; } sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40000000); cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40001000); wr = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40002000); rd = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40003000); rst = cfg + 0; freq = cfg + 4; *rst &= ~6; *freq = (uint32_t)floor(25.0 / 125.0 * (1<<30) + 0.5); *rst |= 1; *rst &= ~1; *wr = 32766; *wr = (uint32_t)floor(0.25 * (1<<30) + 0.5); *wr = 7-2; *wr = 5; *wr = 0; *wr = 0; *wr = 3-2; *wr = 1; *wr = 32766; *wr = (uint32_t)floor(0.25 * (1<<30) + 0.5); *wr = 7-2; *wr = 5; *rst |= 4; *rst |= 2; sleep(1); for(i = 0; i < 100; ++i) { buffer = *rd; value = buffer & 0xffff; printf("%6d %d %d\n", value, (buffer >> 16) & 1, (buffer >> 24) & 1); } return EXIT_SUCCESS; }
the_stack_data/72012540.c
#include <stdio.h> #include <stdlib.h> int main() { int a,b,c,d,f,g,h,i,x,y,z,day,da,hr,ha, mnt, sec; char ab[10],b1,b2,b3,b4,b5,b6,b7,xy[10],y1,y2,y3,y4,y5,y6,y7; scanf("%s%d",&ab,&a); scanf("%d%c%c%c%d%c%c%c%d",&b,&b1,&b2,&b3,&c,&b4,&b5,&b6,&d); scanf("%s%d",&xy,&f); scanf("%d%c%c%c%d%c%c%c%d",&g,&y1,&y2,&y3,&h,&y4,&y5,&y6,&i); x=(a*86400)+(b*3600)+(c*60)+d; y=(f*86400)+(g*3600)+(h*60)+i; z=y-x; day=z/86400; da=z%86400; hr=da/3600; ha=da%3600; mnt=ha/60; sec=ha%60; printf("%d dia(s)\n",day); printf("%d hora(s)\n",hr); printf("%d minuto(s)\n",mnt); printf("%d segundo(s)\n",sec); return 0; }
the_stack_data/948383.c
int printf(); int main(){ int i = 3; if(i != 3){ printf("Error 0 : %d\n", i); return -1; } int a = 0; for(int i = 0; i < 10; i++){ a++; } int b; for(b = 0; b < 10; b++){ a++; } if(i != 3){ printf("Error 1 : %d\n", i); return -1; } if(a != 20){ printf("Error 2 : %d\n", a); return -1; } printf("OK\n"); return 0; }
the_stack_data/12817.c
/* This file is provided under a dual BSD/GPLv2 license. When using or redistributing this file, you may do so under either license. GPL LICENSE SUMMARY Copyright(c) 2016 Intel Corporation. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Contact Information: Intel Corporation, www.intel.com BSD LICENSE Copyright(c) 2016 Intel Corporation. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifdef PSM_CUDA #include "psm_user.h" #include "am_cuda_memhandle_cache.h" /* * rbtree cruft */ struct _cl_map_item; typedef struct { unsigned long start; /* start virtual address */ CUipcMemHandle cuda_ipc_handle; /* cuda ipc mem handle */ CUdeviceptr cuda_ipc_dev_ptr;/* Cuda device pointer */ uint16_t length; /* length*/ psm2_epid_t epid; struct _cl_map_item* i_prev; /* idle queue previous */ struct _cl_map_item* i_next; /* idle queue next */ }__attribute__ ((aligned (128))) rbtree_cuda_memhandle_cache_mapitem_pl_t; typedef struct { uint32_t nelems; /* number of elements in the cache */ } rbtree_cuda_memhandle_cache_map_pl_t; static psm2_error_t am_cuda_memhandle_mpool_init(uint32_t memcache_size); /* * Custom comparator */ typedef rbtree_cuda_memhandle_cache_mapitem_pl_t cuda_cache_item; static int cuda_cache_key_cmp(const cuda_cache_item *a, const cuda_cache_item *b) { // When multi-ep is disabled, cache can assume // 1 epid == 1 remote process == 1 CUDA address space // But when multi-ep is enabled, one process can have many epids, so in this case // cannot use epid as part of cache key. if (!psmi_multi_ep_enabled) { if (a->epid < b->epid) return -1; if (a->epid > b->epid) return 1; } unsigned long a_end, b_end; // normalize into inclusive upper bounds to handle // 0-length entries a_end = (a->start + a->length); b_end = (b->start + b->length); if (a->length > 0) a_end--; if (b->length > 0) b_end--; if (a_end < b->start) return -1; if (b_end < a->start) return 1; return 0; } /* * Necessary rbtree cruft */ #define RBTREE_MI_PL rbtree_cuda_memhandle_cache_mapitem_pl_t #define RBTREE_MAP_PL rbtree_cuda_memhandle_cache_map_pl_t #define RBTREE_CMP(a,b) cuda_cache_key_cmp((a), (b)) #define RBTREE_ASSERT psmi_assert #define RBTREE_MAP_COUNT(PAYLOAD_PTR) ((PAYLOAD_PTR)->nelems) #define RBTREE_NO_EMIT_IPS_CL_QMAP_PREDECESSOR #include "rbtree.h" #include "rbtree.c" /* * Convenience rbtree cruft */ #define NELEMS cuda_memhandle_cachemap.payload.nelems #define IHEAD cuda_memhandle_cachemap.root #define LAST IHEAD->payload.i_prev #define FIRST IHEAD->payload.i_next #define INEXT(x) x->payload.i_next #define IPREV(x) x->payload.i_prev /* * Actual module data */ static cl_qmap_t cuda_memhandle_cachemap; /* Global cache */ static uint8_t cuda_memhandle_cache_enabled; static mpool_t cuda_memhandle_mpool; static uint32_t cuda_memhandle_cache_size; static uint64_t cache_hit_counter; static uint64_t cache_miss_counter; static uint64_t cache_evict_counter; static uint64_t cache_collide_counter; static uint64_t cache_clear_counter; static void print_cuda_memhandle_cache_stats(void) { _HFI_DBG("enabled=%u,size=%u,hit=%lu,miss=%lu,evict=%lu,collide=%lu,clear=%lu\n", cuda_memhandle_cache_enabled, cuda_memhandle_cache_size, cache_hit_counter, cache_miss_counter, cache_evict_counter, cache_collide_counter, cache_clear_counter); } /* * This is the callback function when mempool are resized or destroyed. * Upon calling cache fini mpool is detroyed which in turn calls this callback * which helps in closing all memhandles. */ static void psmi_cuda_memhandle_cache_alloc_func(int is_alloc, void* obj) { cl_map_item_t* memcache_item = (cl_map_item_t*)obj; if (!is_alloc) { if(memcache_item->payload.start) PSMI_CUDA_CALL(cuIpcCloseMemHandle, memcache_item->payload.cuda_ipc_dev_ptr); } } /* * Creating mempool for cuda memhandle cache nodes. */ static psm2_error_t am_cuda_memhandle_mpool_init(uint32_t memcache_size) { psm2_error_t err; if (memcache_size < 1) return PSM2_PARAM_ERR; cuda_memhandle_cache_size = memcache_size; /* Creating a memory pool of size PSM2_CUDA_MEMCACHE_SIZE * which includes the Root and NIL items */ cuda_memhandle_mpool = psmi_mpool_create_for_cuda(sizeof(cl_map_item_t), cuda_memhandle_cache_size, cuda_memhandle_cache_size, 0, UNDEFINED, NULL, NULL, psmi_cuda_memhandle_cache_alloc_func); if (cuda_memhandle_mpool == NULL) { err = psmi_handle_error(PSMI_EP_NORETURN, PSM2_NO_MEMORY, "Couldn't allocate CUDA host receive buffer pool"); return err; } return PSM2_OK; } /* * Initialize rbtree. */ psm2_error_t am_cuda_memhandle_cache_init(uint32_t memcache_size) { psm2_error_t err = am_cuda_memhandle_mpool_init(memcache_size); if (err != PSM2_OK) return err; cl_map_item_t *root, *nil_item; root = (cl_map_item_t *)psmi_calloc(NULL, UNDEFINED, 1, sizeof(cl_map_item_t)); if (root == NULL) return PSM2_NO_MEMORY; nil_item = (cl_map_item_t *)psmi_calloc(NULL, UNDEFINED, 1, sizeof(cl_map_item_t)); if (nil_item == NULL) { psmi_free(root); return PSM2_NO_MEMORY; } nil_item->payload.start = 0; nil_item->payload.epid = 0; nil_item->payload.length = 0; cuda_memhandle_cache_enabled = 1; ips_cl_qmap_init(&cuda_memhandle_cachemap,root,nil_item); NELEMS = 0; cache_hit_counter = 0; cache_miss_counter = 0; cache_evict_counter = 0; cache_collide_counter = 0; cache_clear_counter = 0; return PSM2_OK; } void am_cuda_memhandle_cache_map_fini() { print_cuda_memhandle_cache_stats(); if (cuda_memhandle_cachemap.nil_item) { psmi_free(cuda_memhandle_cachemap.nil_item); cuda_memhandle_cachemap.nil_item = NULL; } if (cuda_memhandle_cachemap.root) { psmi_free(cuda_memhandle_cachemap.root); cuda_memhandle_cachemap.root = NULL; } if (cuda_memhandle_cache_enabled) { psmi_mpool_destroy(cuda_memhandle_mpool); cuda_memhandle_cache_enabled = 0; } cuda_memhandle_cache_size = 0; } /* * Insert at the head of Idleq. */ static void am_cuda_idleq_insert(cl_map_item_t* memcache_item) { if (FIRST == NULL) { FIRST = memcache_item; LAST = memcache_item; return; } INEXT(FIRST) = memcache_item; IPREV(memcache_item) = FIRST; FIRST = memcache_item; INEXT(FIRST) = NULL; return; } /* * Remove least recent used element. */ static void am_cuda_idleq_remove_last(cl_map_item_t* memcache_item) { if (!INEXT(memcache_item)) { LAST = NULL; FIRST = NULL; } else { LAST = INEXT(memcache_item); IPREV(LAST) = NULL; } // Null-out now-removed memcache_item's next and prev pointers out of // an abundance of caution INEXT(memcache_item) = IPREV(memcache_item) = NULL; } static void am_cuda_idleq_remove(cl_map_item_t* memcache_item) { if (LAST == memcache_item) { am_cuda_idleq_remove_last(memcache_item); } else if (FIRST == memcache_item) { FIRST = IPREV(memcache_item); INEXT(FIRST) = NULL; } else { INEXT(IPREV(memcache_item)) = INEXT(memcache_item); IPREV(INEXT(memcache_item)) = IPREV(memcache_item); } // Null-out now-removed memcache_item's next and prev pointers out of // an abundance of caution INEXT(memcache_item) = IPREV(memcache_item) = NULL; } static void am_cuda_idleq_reorder(cl_map_item_t* memcache_item) { if (FIRST == memcache_item && LAST == memcache_item ) { return; } am_cuda_idleq_remove(memcache_item); am_cuda_idleq_insert(memcache_item); return; } /* * After a successful cache hit, item is validated by doing a * memcmp on the handle stored and the handle we recieve from the * sender. If the validation fails the item is removed from the idleq, * the rbtree, is put back into the mpool and IpcCloseMemHandle function * is called. */ static psm2_error_t am_cuda_memhandle_cache_validate(cl_map_item_t* memcache_item, uintptr_t sbuf, CUipcMemHandle* handle, uint32_t length, psm2_epid_t epid) { if ((0 == memcmp(handle, &memcache_item->payload.cuda_ipc_handle, sizeof(CUipcMemHandle))) && sbuf == memcache_item->payload.start && epid == memcache_item->payload.epid) { return PSM2_OK; } _HFI_DBG("cache collision: new entry start=%lu,length=%u\n", sbuf, length); cache_collide_counter++; ips_cl_qmap_remove_item(&cuda_memhandle_cachemap, memcache_item); PSMI_CUDA_CALL(cuIpcCloseMemHandle, memcache_item->payload.cuda_ipc_dev_ptr); am_cuda_idleq_remove(memcache_item); memset(memcache_item, 0, sizeof(*memcache_item)); psmi_mpool_put(memcache_item); return PSM2_OK_NO_PROGRESS; } /* * Current eviction policy: Least Recently Used. */ static void am_cuda_memhandle_cache_evict(void) { cache_evict_counter++; cl_map_item_t *p_item = LAST; _HFI_VDBG("Removing (epid=%lu,start=%lu,length=%u,dev_ptr=0x%llX,it=%p) from cuda_memhandle_cachemap.\n", p_item->payload.epid, p_item->payload.start, p_item->payload.length, p_item->payload.cuda_ipc_dev_ptr, p_item); ips_cl_qmap_remove_item(&cuda_memhandle_cachemap, p_item); PSMI_CUDA_CALL(cuIpcCloseMemHandle, p_item->payload.cuda_ipc_dev_ptr); am_cuda_idleq_remove_last(p_item); memset(p_item, 0, sizeof(*p_item)); psmi_mpool_put(p_item); } static psm2_error_t am_cuda_memhandle_cache_register(uintptr_t sbuf, CUipcMemHandle* handle, uint32_t length, psm2_epid_t epid, CUdeviceptr cuda_ipc_dev_ptr) { if (NELEMS == cuda_memhandle_cache_size) am_cuda_memhandle_cache_evict(); cl_map_item_t* memcache_item = psmi_mpool_get(cuda_memhandle_mpool); /* memcache_item cannot be NULL as we evict * before the call to mpool_get. Check has * been fixed to help with klockwork analysis. */ if (memcache_item == NULL) return PSM2_NO_MEMORY; memcache_item->payload.start = sbuf; memcache_item->payload.cuda_ipc_handle = *handle; memcache_item->payload.cuda_ipc_dev_ptr = cuda_ipc_dev_ptr; memcache_item->payload.length = length; memcache_item->payload.epid = epid; ips_cl_qmap_insert_item(&cuda_memhandle_cachemap, memcache_item); am_cuda_idleq_insert(memcache_item); return PSM2_OK; } static void am_cuda_memhandle_cache_clear(void) { _HFI_DBG("Closing all handles, clearing cuda_memhandle_cachemap and idleq. NELEMS=%u\n", NELEMS); while (NELEMS) { am_cuda_memhandle_cache_evict(); } _HFI_DBG("Closed all handles, cleared cuda_memhandle_cachemap and idleq. NELEMS=%u\n", NELEMS); } /* * The key used to search the cache is the senders buf address pointer. * Upon a succesful hit in the cache, additional validation is required * as multiple senders could potentially send the same buf address value. */ CUdeviceptr am_cuda_memhandle_acquire(uintptr_t sbuf, CUipcMemHandle* handle, uint32_t length, psm2_epid_t epid) { _HFI_VDBG("sbuf=%lu,handle=%p,length=%u,epid=%lu\n", sbuf, handle, length, epid); CUdeviceptr cuda_ipc_dev_ptr; if(!cuda_memhandle_cache_enabled) { PSMI_CUDA_CALL(cuIpcOpenMemHandle, &cuda_ipc_dev_ptr, *handle, CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS); return cuda_ipc_dev_ptr; } cuda_cache_item key = { .start = (unsigned long) sbuf, .length= length, .epid = epid }; /* * preconditions: * 1) newrange [start,end) may or may not be in cachemap already * 2) there are no overlapping address ranges in cachemap * postconditions: * 1) newrange is in cachemap * 2) there are no overlapping address ranges in cachemap * * The key used to search the cache is the senders buf address pointer. * Upon a succesful hit in the cache, additional validation is required * as multiple senders could potentially send the same buf address value. */ cl_map_item_t *p_item = ips_cl_qmap_searchv(&cuda_memhandle_cachemap, &key); while (p_item->payload.start) { // Since a precondition is that there are no overlapping ranges in cachemap, // an exact match implies no need to check further if (am_cuda_memhandle_cache_validate(p_item, sbuf, handle, length, epid) == PSM2_OK) { cache_hit_counter++; am_cuda_idleq_reorder(p_item); return p_item->payload.cuda_ipc_dev_ptr; } // newrange is not in the cache and overlaps at least one existing range. // am_cuda_memhandle_cache_validate() closed and removed existing range. // Continue searching for more overlapping ranges p_item = ips_cl_qmap_searchv(&cuda_memhandle_cachemap, &key); } cache_miss_counter++; CUresult cudaerr; PSMI_CUDA_CALL_EXCEPT(CUDA_ERROR_ALREADY_MAPPED, cuIpcOpenMemHandle, &cuda_ipc_dev_ptr, *handle, CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS); if (cudaerr == CUDA_ERROR_ALREADY_MAPPED) { // remote memory already mapped. Close all handles, clear cache, // and try again am_cuda_memhandle_cache_clear(); cache_clear_counter++; PSMI_CUDA_CALL(cuIpcOpenMemHandle, &cuda_ipc_dev_ptr, *handle, CU_IPC_MEM_LAZY_ENABLE_PEER_ACCESS); } am_cuda_memhandle_cache_register(sbuf, handle, length, epid, cuda_ipc_dev_ptr); return cuda_ipc_dev_ptr; } void am_cuda_memhandle_release(CUdeviceptr cuda_ipc_dev_ptr) { if(!cuda_memhandle_cache_enabled) PSMI_CUDA_CALL(cuIpcCloseMemHandle, cuda_ipc_dev_ptr); return; } #endif
the_stack_data/493977.c
#include <stdio.h> #include <stdlib.h> #include <mqueue.h> #include <sys/stat.h> #define GET_QUEUE "/get_queue" #define RET_QUEUE "/ret_queue" mqd_t get_queue; mqd_t ret_queue; struct mq_attr attr; int ticket, msg = 1; int request_valid = 0; void open_queues(){ if((get_queue = mq_open(GET_QUEUE, O_RDWR|O_CREAT, 0666, &attr)) < 0){ perror("get mq_open"); exit(1); } if((ret_queue = mq_open(RET_QUEUE, O_RDWR|O_CREAT)) < 0){ perror("ret mq_open"); exit(1); } } int request_ticket(){ int send = mq_send (get_queue, (void *) &msg, sizeof(msg), 0); if (send < 0){ perror("mq_send"); exit(1); }else{ return 1; } } int receive_ticket(int ticket){ int receive = mq_receive(ret_queue, (void*) &ticket, sizeof(ticket), 0); if(receive < 0){ perror("mq_receive:"); exit(1); } return ticket; } void give_back_ticket(int ticket){ if((ret_queue = mq_open(RET_QUEUE, O_RDWR)) < 0){ perror("ret mq_open"); exit(1); } } int main(){ attr.mq_maxmsg = 10; attr.mq_msgsize = sizeof(ticket)*2; attr.mq_flags = 0; open_queues(); for(;;){ msg = 1; printf("Solicitando ticket!\n"); request_ticket(); printf("Ticket solicitado!\n"); receive_ticket(ticket); printf("Ticket recebido: %d\n", ticket); } }
the_stack_data/193894097.c
/* origin: FreeBSD /usr/src/lib/msun/src/e_log10.c */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunSoft, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ /* * Return the base 10 logarithm of x. See log.c for most comments. * * Reduce x to 2^k (1+f) and calculate r = log(1+f) - f + f*f/2 * as in log.c, then combine and scale in extra precision: * log10(x) = (f - f*f/2 + r)/log(10) + k*log10(2) */ #include <math.h> #include <stdint.h> static const double ivln10hi = 4.34294481878168880939e-01, /* 0x3fdbcb7b, 0x15200000 */ ivln10lo = 2.50829467116452752298e-11, /* 0x3dbb9438, 0xca9aadd5 */ log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */ log10_2lo = 3.69423907715893078616e-13, /* 0x3D59FEF3, 0x11F12B36 */ Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ double log10(double x) { union { double f; uint64_t i; } u = {x}; double_t hfsq, f, s, z, R, w, t1, t2, dk, y, hi, lo, val_hi, val_lo; uint32_t hx; int k; hx = u.i >> 32; k = 0; if (hx < 0x00100000 || hx >> 31) { if (u.i << 1 == 0) return -1 / (x * x); /* log(+-0)=-inf */ if (hx >> 31) return (x - x) / 0.0; /* log(-#) = NaN */ /* subnormal number, scale x up */ k -= 54; x *= 0x1p54; u.f = x; hx = u.i >> 32; } else if (hx >= 0x7ff00000) { return x; } else if (hx == 0x3ff00000 && u.i << 32 == 0) return 0; /* reduce x into [sqrt(2)/2, sqrt(2)] */ hx += 0x3ff00000 - 0x3fe6a09e; k += (int)(hx >> 20) - 0x3ff; hx = (hx & 0x000fffff) + 0x3fe6a09e; u.i = (uint64_t)hx << 32 | (u.i & 0xffffffff); x = u.f; f = x - 1.0; hfsq = 0.5 * f * f; s = f / (2.0 + f); z = s * s; w = z * z; t1 = w * (Lg2 + w * (Lg4 + w * Lg6)); t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7))); R = t2 + t1; /* See log2.c for details. */ /* hi+lo = f - hfsq + s*(hfsq+R) ~ log(1+f) */ hi = f - hfsq; u.f = hi; u.i &= (uint64_t)-1 << 32; hi = u.f; lo = f - hi - hfsq + s * (hfsq + R); /* val_hi+val_lo ~ log10(1+f) + k*log10(2) */ val_hi = hi * ivln10hi; dk = k; y = dk * log10_2hi; val_lo = dk * log10_2lo + (lo + hi) * ivln10lo + lo * ivln10hi; /* * Extra precision in for adding y is not strictly needed * since there is no very large cancellation near x = sqrt(2) or * x = 1/sqrt(2), but we do it anyway since it costs little on CPUs * with some parallelism and it reduces the error for many args. */ w = y + val_hi; val_lo += (y - w) + val_hi; val_hi = w; return val_lo + val_hi; }
the_stack_data/5414.c
// C11 standard // created by cicek on 10.11.2018 00:39 #include <stdio.h> #include <stdlib.h> #include <memory.h> int main() { // Allocating Memory for Strings // // When allocating memory for a string pointer, you may want to use string length rather than the sizeof operator for calculating bytes. char str20[20]; char *str = NULL; strcpy(str20, "12345"); printf("str20 size: %ld\n", sizeof(str20)); printf("str20 length: %ld\n", strlen(str20)); str = malloc(strlen(str20)+1); /* make room for \0 */ strcpy(str, str20); printf("%s", str); /* This approach is better memory management because you aren’t allocating more space than is needed to a pointer. When using strlen to determine the number of bytes needed for a string, be sure to include one extra byte for the NULL character '\0'. A char is always one byte, so there is no need to multiply the memory requirements by sizeof(char). */ int *a = (int*)malloc(10 * sizeof(int)); for (int i = 0; i < 10; ++i) { *(a+i) = i; printf("%d: %d\n", i, a[i]); } return 0; }
the_stack_data/6387944.c
/* * Copyright 2015-2020 Leonid Yuriev <[email protected]> * and other libmdbx authors: please see AUTHORS file. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted only as authorized by the OpenLDAP * Public License. * * A copy of this license is available in the file LICENSE in the * top-level directory of the distribution or, alternatively, at * <http://www.OpenLDAP.org/license.html>. */ #if defined(_WIN32) || defined(_WIN64) /* Windows LCK-implementation */ /* PREAMBLE FOR WINDOWS: * * We are not concerned for performance here. * If you are running Windows a performance could NOT be the goal. * Otherwise please use Linux. */ #include "internals.h" static void mdbx_winnt_import(void); #if MDBX_BUILD_SHARED_LIBRARY #if MDBX_AVOID_CRT && defined(NDEBUG) /* DEBUG/CHECKED builds still require MSVC's CRT for runtime checks. * * Define dll's entry point only for Release build when NDEBUG is defined and * MDBX_AVOID_CRT=ON. if the entry point isn't defined then MSVC's will * automatically use DllMainCRTStartup() from CRT library, which also * automatically call DllMain() from our mdbx.dll */ #pragma comment(linker, "/ENTRY:DllMain") #endif /* MDBX_AVOID_CRT */ BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID reserved) #else #if !MDBX_CONFIG_MANUAL_TLS_CALLBACK static #endif /* !MDBX_CONFIG_MANUAL_TLS_CALLBACK */ void NTAPI mdbx_dll_handler(PVOID module, DWORD reason, PVOID reserved) #endif /* MDBX_BUILD_SHARED_LIBRARY */ { (void)reserved; switch (reason) { case DLL_PROCESS_ATTACH: mdbx_winnt_import(); mdbx_rthc_global_init(); break; case DLL_PROCESS_DETACH: mdbx_rthc_global_dtor(); break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: mdbx_rthc_thread_dtor(module); break; } #if MDBX_BUILD_SHARED_LIBRARY return TRUE; #endif } #if !MDBX_BUILD_SHARED_LIBRARY && !MDBX_CONFIG_MANUAL_TLS_CALLBACK /* *INDENT-OFF* */ /* clang-format off */ #if defined(_MSC_VER) # pragma const_seg(push) # pragma data_seg(push) # ifdef _WIN64 /* kick a linker to create the TLS directory if not already done */ # pragma comment(linker, "/INCLUDE:_tls_used") /* Force some symbol references. */ # pragma comment(linker, "/INCLUDE:mdbx_tls_anchor") /* specific const-segment for WIN64 */ # pragma const_seg(".CRT$XLB") const # else /* kick a linker to create the TLS directory if not already done */ # pragma comment(linker, "/INCLUDE:__tls_used") /* Force some symbol references. */ # pragma comment(linker, "/INCLUDE:_mdbx_tls_anchor") /* specific data-segment for WIN32 */ # pragma data_seg(".CRT$XLB") # endif __declspec(allocate(".CRT$XLB")) PIMAGE_TLS_CALLBACK mdbx_tls_anchor = mdbx_dll_handler; # pragma data_seg(pop) # pragma const_seg(pop) #elif defined(__GNUC__) # ifdef _WIN64 const # endif PIMAGE_TLS_CALLBACK mdbx_tls_anchor __attribute__((__section__(".CRT$XLB"), used)) = mdbx_dll_handler; #else # error FIXME #endif /* *INDENT-ON* */ /* clang-format on */ #endif /* !MDBX_BUILD_SHARED_LIBRARY && !MDBX_CONFIG_MANUAL_TLS_CALLBACK */ /*----------------------------------------------------------------------------*/ #define LCK_SHARED 0 #define LCK_EXCLUSIVE LOCKFILE_EXCLUSIVE_LOCK #define LCK_WAITFOR 0 #define LCK_DONTWAIT LOCKFILE_FAIL_IMMEDIATELY static __inline BOOL flock(mdbx_filehandle_t fd, DWORD flags, uint64_t offset, size_t bytes) { OVERLAPPED ov; ov.hEvent = 0; ov.Offset = (DWORD)offset; ov.OffsetHigh = HIGH_DWORD(offset); return LockFileEx(fd, flags, 0, (DWORD)bytes, HIGH_DWORD(bytes), &ov); } static __inline BOOL funlock(mdbx_filehandle_t fd, uint64_t offset, size_t bytes) { return UnlockFile(fd, (DWORD)offset, HIGH_DWORD(offset), (DWORD)bytes, HIGH_DWORD(bytes)); } /*----------------------------------------------------------------------------*/ /* global `write` lock for write-txt processing, * exclusive locking both meta-pages) */ #define LCK_MAXLEN (1u + (size_t)(MAXSSIZE_T)) #define LCK_META_OFFSET 0 #define LCK_META_LEN (MAX_PAGESIZE * NUM_METAS) #define LCK_BODY_OFFSET LCK_META_LEN #define LCK_BODY_LEN (LCK_MAXLEN - LCK_BODY_OFFSET) #define LCK_BODY LCK_BODY_OFFSET, LCK_BODY_LEN #define LCK_WHOLE 0, LCK_MAXLEN int mdbx_txn_lock(MDBX_env *env, bool dontwait) { if (dontwait) { if (!TryEnterCriticalSection(&env->me_windowsbug_lock)) return MDBX_BUSY; } else { EnterCriticalSection(&env->me_windowsbug_lock); } if ((env->me_flags & MDBX_EXCLUSIVE) || flock(env->me_lazy_fd, dontwait ? (LCK_EXCLUSIVE | LCK_DONTWAIT) : (LCK_EXCLUSIVE | LCK_WAITFOR), LCK_BODY)) return MDBX_SUCCESS; int rc = GetLastError(); LeaveCriticalSection(&env->me_windowsbug_lock); return (!dontwait || rc != ERROR_LOCK_VIOLATION) ? rc : MDBX_BUSY; } void mdbx_txn_unlock(MDBX_env *env) { int rc = (env->me_flags & MDBX_EXCLUSIVE) ? TRUE : funlock(env->me_lazy_fd, LCK_BODY); LeaveCriticalSection(&env->me_windowsbug_lock); if (!rc) mdbx_panic("%s failed: err %u", __func__, GetLastError()); } /*----------------------------------------------------------------------------*/ /* global `read` lock for readers registration, * exclusive locking `mti_numreaders` (second) cacheline */ #define LCK_LO_OFFSET 0 #define LCK_LO_LEN offsetof(MDBX_lockinfo, mti_numreaders) #define LCK_UP_OFFSET LCK_LO_LEN #define LCK_UP_LEN (sizeof(MDBX_lockinfo) - LCK_UP_OFFSET) #define LCK_LOWER LCK_LO_OFFSET, LCK_LO_LEN #define LCK_UPPER LCK_UP_OFFSET, LCK_UP_LEN MDBX_INTERNAL_FUNC int mdbx_rdt_lock(MDBX_env *env) { mdbx_srwlock_AcquireShared(&env->me_remap_guard); if (env->me_lfd == INVALID_HANDLE_VALUE) return MDBX_SUCCESS; /* readonly database in readonly filesystem */ /* transite from S-? (used) to S-E (locked), e.g. exclusive lock upper-part */ if ((env->me_flags & MDBX_EXCLUSIVE) || flock(env->me_lfd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_UPPER)) return MDBX_SUCCESS; int rc = GetLastError(); mdbx_srwlock_ReleaseShared(&env->me_remap_guard); return rc; } MDBX_INTERNAL_FUNC void mdbx_rdt_unlock(MDBX_env *env) { if (env->me_lfd != INVALID_HANDLE_VALUE) { /* transite from S-E (locked) to S-? (used), e.g. unlock upper-part */ if ((env->me_flags & MDBX_EXCLUSIVE) == 0 && !funlock(env->me_lfd, LCK_UPPER)) mdbx_panic("%s failed: err %u", __func__, GetLastError()); } mdbx_srwlock_ReleaseShared(&env->me_remap_guard); } static int suspend_and_append(mdbx_handle_array_t **array, const DWORD ThreadId) { const unsigned limit = (*array)->limit; if ((*array)->count == limit) { void *ptr = mdbx_realloc( (limit > ARRAY_LENGTH((*array)->handles)) ? *array : /* don't free initial array on the stack */ NULL, sizeof(mdbx_handle_array_t) + sizeof(HANDLE) * (limit * 2 - ARRAY_LENGTH((*array)->handles))); if (!ptr) return MDBX_ENOMEM; if (limit == ARRAY_LENGTH((*array)->handles)) memcpy(ptr, *array, sizeof(mdbx_handle_array_t)); *array = (mdbx_handle_array_t *)ptr; (*array)->limit = limit * 2; } HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME | THREAD_QUERY_INFORMATION, FALSE, ThreadId); if (hThread == NULL) return GetLastError(); if (SuspendThread(hThread) == -1) { int err = GetLastError(); DWORD ExitCode; if (err == /* workaround for Win10 UCRT bug */ ERROR_ACCESS_DENIED || !GetExitCodeThread(hThread, &ExitCode) || ExitCode != STILL_ACTIVE) err = MDBX_SUCCESS; CloseHandle(hThread); return err; } (*array)->handles[(*array)->count++] = hThread; return MDBX_SUCCESS; } MDBX_INTERNAL_FUNC int mdbx_suspend_threads_before_remap(MDBX_env *env, mdbx_handle_array_t **array) { const uintptr_t CurrentTid = GetCurrentThreadId(); int rc; if (env->me_lck) { /* Scan LCK for threads of the current process */ const MDBX_reader *const begin = env->me_lck->mti_readers; const MDBX_reader *const end = begin + env->me_lck->mti_numreaders; const uintptr_t WriteTxnOwner = env->me_txn0 ? env->me_txn0->mt_owner : 0; for (const MDBX_reader *reader = begin; reader < end; ++reader) { if (reader->mr_pid != env->me_pid || !reader->mr_tid) { skip_lck: continue; } if (reader->mr_tid == CurrentTid || reader->mr_tid == WriteTxnOwner) goto skip_lck; if (env->me_flags & MDBX_NOTLS) { /* Skip duplicates in no-tls mode */ for (const MDBX_reader *scan = reader; --scan >= begin;) if (scan->mr_tid == reader->mr_tid) goto skip_lck; } rc = suspend_and_append(array, (mdbx_tid_t)reader->mr_tid); if (rc != MDBX_SUCCESS) { bailout_lck: (void)mdbx_resume_threads_after_remap(*array); return rc; } } if (WriteTxnOwner && WriteTxnOwner != CurrentTid) { rc = suspend_and_append(array, (mdbx_tid_t)WriteTxnOwner); if (rc != MDBX_SUCCESS) goto bailout_lck; } } else { /* Without LCK (i.e. read-only mode). * Walk thougth a snapshot of all running threads */ mdbx_assert(env, env->me_txn0 == NULL || (env->me_flags & MDBX_EXCLUSIVE) != 0); const HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); if (hSnapshot == INVALID_HANDLE_VALUE) return GetLastError(); THREADENTRY32 entry; entry.dwSize = sizeof(THREADENTRY32); if (!Thread32First(hSnapshot, &entry)) { rc = GetLastError(); bailout_toolhelp: CloseHandle(hSnapshot); (void)mdbx_resume_threads_after_remap(*array); return rc; } do { if (entry.th32OwnerProcessID != env->me_pid || entry.th32ThreadID == CurrentTid) continue; rc = suspend_and_append(array, entry.th32ThreadID); if (rc != MDBX_SUCCESS) goto bailout_toolhelp; } while (Thread32Next(hSnapshot, &entry)); rc = GetLastError(); if (rc != ERROR_NO_MORE_FILES) goto bailout_toolhelp; CloseHandle(hSnapshot); } return MDBX_SUCCESS; } MDBX_INTERNAL_FUNC int mdbx_resume_threads_after_remap(mdbx_handle_array_t *array) { int rc = MDBX_SUCCESS; for (unsigned i = 0; i < array->count; ++i) { const HANDLE hThread = array->handles[i]; if (ResumeThread(hThread) == -1) { const int err = GetLastError(); DWORD ExitCode; if (err != /* workaround for Win10 UCRT bug */ ERROR_ACCESS_DENIED && GetExitCodeThread(hThread, &ExitCode) && ExitCode == STILL_ACTIVE) rc = err; } CloseHandle(hThread); } return rc; } /*----------------------------------------------------------------------------*/ /* global `initial` lock for lockfile initialization, * exclusive/shared locking first cacheline */ /* Briefly descritpion of locking schema/algorithm: * - Windows does not support upgrading or downgrading for file locking. * - Therefore upgrading/downgrading is emulated by shared and exclusive * locking of upper and lower halves. * - In other words, we have FSM with possible 9 states, * i.e. free/shared/exclusive x free/shared/exclusive == 9. * Only 6 states of FSM are used, which 2 of ones are transitive. * * States: * ?-? = free, i.e. unlocked * S-? = used, i.e. shared lock * E-? = exclusive-read, i.e. operational exclusive * ?-S * ?-E = middle (transitive state) * S-S * S-E = locked (transitive state) * E-S * E-E = exclusive-write, i.e. exclusive due (re)initialization * * The mdbx_lck_seize() moves the locking-FSM from the initial free/unlocked * state to the "exclusive write" (and returns MDBX_RESULT_TRUE) if possible, * or to the "used" (and returns MDBX_RESULT_FALSE). * * The mdbx_lck_downgrade() moves the locking-FSM from "exclusive write" * state to the "used" (i.e. shared) state. * * The mdbx_lck_upgrade() moves the locking-FSM from "used" (i.e. shared) * state to the "exclusive write" state. */ static void lck_unlock(MDBX_env *env) { int err; if (env->me_lfd != INVALID_HANDLE_VALUE) { /* double `unlock` for robustly remove overlapped shared/exclusive locks */ while (funlock(env->me_lfd, LCK_LOWER)) ; err = GetLastError(); assert(err == ERROR_NOT_LOCKED || (mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION)); (void)err; SetLastError(ERROR_SUCCESS); while (funlock(env->me_lfd, LCK_UPPER)) ; err = GetLastError(); assert(err == ERROR_NOT_LOCKED || (mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION)); (void)err; SetLastError(ERROR_SUCCESS); } if (env->me_lazy_fd != INVALID_HANDLE_VALUE) { /* explicitly unlock to avoid latency for other processes (windows kernel * releases such locks via deferred queues) */ while (funlock(env->me_lazy_fd, LCK_BODY)) ; err = GetLastError(); assert(err == ERROR_NOT_LOCKED || (mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION)); (void)err; SetLastError(ERROR_SUCCESS); while (funlock(env->me_lazy_fd, LCK_WHOLE)) ; err = GetLastError(); assert(err == ERROR_NOT_LOCKED || (mdbx_RunningUnderWine() && err == ERROR_LOCK_VIOLATION)); (void)err; SetLastError(ERROR_SUCCESS); } } /* Seize state as 'exclusive-write' (E-E and returns MDBX_RESULT_TRUE) * or as 'used' (S-? and returns MDBX_RESULT_FALSE). * Oherwise returns an error. */ static int internal_seize_lck(HANDLE lfd) { int rc; assert(lfd != INVALID_HANDLE_VALUE); /* 1) now on ?-? (free), get ?-E (middle) */ mdbx_jitter4testing(false); if (!flock(lfd, LCK_EXCLUSIVE | LCK_WAITFOR, LCK_UPPER)) { rc = GetLastError() /* 2) something went wrong, give up */; mdbx_error("%s, err %u", "?-?(free) >> ?-E(middle)", rc); return rc; } /* 3) now on ?-E (middle), try E-E (exclusive-write) */ mdbx_jitter4testing(false); if (flock(lfd, LCK_EXCLUSIVE | LCK_DONTWAIT, LCK_LOWER)) return MDBX_RESULT_TRUE /* 4) got E-E (exclusive-write), done */; /* 5) still on ?-E (middle) */ rc = GetLastError(); mdbx_jitter4testing(false); if (rc != ERROR_SHARING_VIOLATION && rc != ERROR_LOCK_VIOLATION) { /* 6) something went wrong, give up */ if (!funlock(lfd, LCK_UPPER)) mdbx_panic("%s(%s) failed: err %u", __func__, "?-E(middle) >> ?-?(free)", GetLastError()); return rc; } /* 7) still on ?-E (middle), try S-E (locked) */ mdbx_jitter4testing(false); rc = flock(lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER) ? MDBX_RESULT_FALSE : GetLastError(); mdbx_jitter4testing(false); if (rc != MDBX_RESULT_FALSE) mdbx_error("%s, err %u", "?-E(middle) >> S-E(locked)", rc); /* 8) now on S-E (locked) or still on ?-E (middle), * transite to S-? (used) or ?-? (free) */ if (!funlock(lfd, LCK_UPPER)) mdbx_panic("%s(%s) failed: err %u", __func__, "X-E(locked/middle) >> X-?(used/free)", GetLastError()); /* 9) now on S-? (used, DONE) or ?-? (free, FAILURE) */ return rc; } MDBX_INTERNAL_FUNC int mdbx_lck_seize(MDBX_env *env) { int rc; assert(env->me_lazy_fd != INVALID_HANDLE_VALUE); if (env->me_flags & MDBX_EXCLUSIVE) return MDBX_RESULT_TRUE /* nope since files were must be opened non-shareable */ ; if (env->me_lfd == INVALID_HANDLE_VALUE) { /* LY: without-lck mode (e.g. on read-only filesystem) */ mdbx_jitter4testing(false); if (!flock(env->me_lazy_fd, LCK_SHARED | LCK_DONTWAIT, LCK_WHOLE)) { rc = GetLastError(); mdbx_error("%s, err %u", "without-lck", rc); return rc; } return MDBX_RESULT_FALSE; } rc = internal_seize_lck(env->me_lfd); mdbx_jitter4testing(false); if (rc == MDBX_RESULT_TRUE && (env->me_flags & MDBX_RDONLY) == 0) { /* Check that another process don't operates in without-lck mode. * Doing such check by exclusive locking the body-part of db. Should be * noted: * - we need an exclusive lock for do so; * - we can't lock meta-pages, otherwise other process could get an error * while opening db in valid (non-conflict) mode. */ if (!flock(env->me_lazy_fd, LCK_EXCLUSIVE | LCK_DONTWAIT, LCK_BODY)) { rc = GetLastError(); mdbx_error("%s, err %u", "lock-against-without-lck", rc); mdbx_jitter4testing(false); lck_unlock(env); } else { mdbx_jitter4testing(false); if (!funlock(env->me_lazy_fd, LCK_BODY)) mdbx_panic("%s(%s) failed: err %u", __func__, "unlock-against-without-lck", GetLastError()); } } return rc; } MDBX_INTERNAL_FUNC int mdbx_lck_downgrade(MDBX_env *env) { /* Transite from exclusive-write state (E-E) to used (S-?) */ assert(env->me_lazy_fd != INVALID_HANDLE_VALUE); assert(env->me_lfd != INVALID_HANDLE_VALUE); if (env->me_flags & MDBX_EXCLUSIVE) return MDBX_SUCCESS /* nope since files were must be opened non-shareable */ ; /* 1) now at E-E (exclusive-write), transite to ?_E (middle) */ if (!funlock(env->me_lfd, LCK_LOWER)) mdbx_panic("%s(%s) failed: err %u", __func__, "E-E(exclusive-write) >> ?-E(middle)", GetLastError()); /* 2) now at ?-E (middle), transite to S-E (locked) */ if (!flock(env->me_lfd, LCK_SHARED | LCK_DONTWAIT, LCK_LOWER)) { int rc = GetLastError() /* 3) something went wrong, give up */; mdbx_error("%s, err %u", "?-E(middle) >> S-E(locked)", rc); return rc; } /* 4) got S-E (locked), continue transition to S-? (used) */ if (!funlock(env->me_lfd, LCK_UPPER)) mdbx_panic("%s(%s) failed: err %u", __func__, "S-E(locked) >> S-?(used)", GetLastError()); return MDBX_SUCCESS /* 5) now at S-? (used), done */; } MDBX_INTERNAL_FUNC int mdbx_lck_upgrade(MDBX_env *env) { /* Transite from used state (S-?) to exclusive-write (E-E) */ assert(env->me_lfd != INVALID_HANDLE_VALUE); if (env->me_flags & MDBX_EXCLUSIVE) return MDBX_SUCCESS /* nope since files were must be opened non-shareable */ ; int rc; /* 1) now on S-? (used), try S-E (locked) */ mdbx_jitter4testing(false); if (!flock(env->me_lfd, LCK_EXCLUSIVE | LCK_DONTWAIT, LCK_UPPER)) { rc = GetLastError() /* 2) something went wrong, give up */; mdbx_verbose("%s, err %u", "S-?(used) >> S-E(locked)", rc); return rc; } /* 3) now on S-E (locked), transite to ?-E (middle) */ if (!funlock(env->me_lfd, LCK_LOWER)) mdbx_panic("%s(%s) failed: err %u", __func__, "S-E(locked) >> ?-E(middle)", GetLastError()); /* 4) now on ?-E (middle), try E-E (exclusive-write) */ mdbx_jitter4testing(false); if (!flock(env->me_lfd, LCK_EXCLUSIVE | LCK_DONTWAIT, LCK_LOWER)) { rc = GetLastError() /* 5) something went wrong, give up */; mdbx_verbose("%s, err %u", "?-E(middle) >> E-E(exclusive-write)", rc); return rc; } return MDBX_SUCCESS /* 6) now at E-E (exclusive-write), done */; } MDBX_INTERNAL_FUNC int mdbx_lck_init(MDBX_env *env, MDBX_env *inprocess_neighbor, int global_uniqueness_flag) { (void)env; (void)inprocess_neighbor; (void)global_uniqueness_flag; return MDBX_SUCCESS; } MDBX_INTERNAL_FUNC int mdbx_lck_destroy(MDBX_env *env, MDBX_env *inprocess_neighbor) { /* LY: should unmap before releasing the locks to avoid race condition and * STATUS_USER_MAPPED_FILE/ERROR_USER_MAPPED_FILE */ if (env->me_map) mdbx_munmap(&env->me_dxb_mmap); if (env->me_lck) { const bool synced = env->me_lck_mmap.lck->mti_unsynced_pages == 0; mdbx_munmap(&env->me_lck_mmap); if (synced && !inprocess_neighbor && env->me_lfd != INVALID_HANDLE_VALUE && mdbx_lck_upgrade(env) == MDBX_SUCCESS) /* this will fail if LCK is used/mmapped by other process(es) */ mdbx_ftruncate(env->me_lfd, 0); } lck_unlock(env); return MDBX_SUCCESS; } /*----------------------------------------------------------------------------*/ /* reader checking (by pid) */ MDBX_INTERNAL_FUNC int mdbx_rpid_set(MDBX_env *env) { (void)env; return MDBX_SUCCESS; } MDBX_INTERNAL_FUNC int mdbx_rpid_clear(MDBX_env *env) { (void)env; return MDBX_SUCCESS; } /* Checks reader by pid. * * Returns: * MDBX_RESULT_TRUE, if pid is live (unable to acquire lock) * MDBX_RESULT_FALSE, if pid is dead (lock acquired) * or otherwise the errcode. */ MDBX_INTERNAL_FUNC int mdbx_rpid_check(MDBX_env *env, uint32_t pid) { (void)env; HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, pid); int rc; if (likely(hProcess)) { rc = WaitForSingleObject(hProcess, 0); if (unlikely(rc == WAIT_FAILED)) rc = GetLastError(); CloseHandle(hProcess); } else { rc = GetLastError(); } switch (rc) { case ERROR_INVALID_PARAMETER: /* pid seems invalid */ return MDBX_RESULT_FALSE; case WAIT_OBJECT_0: /* process just exited */ return MDBX_RESULT_FALSE; case ERROR_ACCESS_DENIED: /* The ERROR_ACCESS_DENIED would be returned for CSRSS-processes, etc. * assume pid exists */ return MDBX_RESULT_TRUE; case WAIT_TIMEOUT: /* pid running */ return MDBX_RESULT_TRUE; default: /* failure */ return rc; } } //---------------------------------------------------------------------------- // Stub for slim read-write lock // Copyright (C) 1995-2002 Brad Wilson static void WINAPI stub_srwlock_Init(MDBX_srwlock *srwl) { srwl->readerCount = srwl->writerCount = 0; } static void WINAPI stub_srwlock_AcquireShared(MDBX_srwlock *srwl) { while (true) { assert(srwl->writerCount >= 0 && srwl->readerCount >= 0); // If there's a writer already, spin without unnecessarily // interlocking the CPUs if (srwl->writerCount != 0) { YieldProcessor(); continue; } // Add to the readers list _InterlockedIncrement(&srwl->readerCount); // Check for writers again (we may have been pre-empted). If // there are no writers writing or waiting, then we're done. if (srwl->writerCount == 0) break; // Remove from the readers list, spin, try again _InterlockedDecrement(&srwl->readerCount); YieldProcessor(); } } static void WINAPI stub_srwlock_ReleaseShared(MDBX_srwlock *srwl) { assert(srwl->readerCount > 0); _InterlockedDecrement(&srwl->readerCount); } static void WINAPI stub_srwlock_AcquireExclusive(MDBX_srwlock *srwl) { while (true) { assert(srwl->writerCount >= 0 && srwl->readerCount >= 0); // If there's a writer already, spin without unnecessarily // interlocking the CPUs if (srwl->writerCount != 0) { YieldProcessor(); continue; } // See if we can become the writer (expensive, because it inter- // locks the CPUs, so writing should be an infrequent process) if (_InterlockedExchange(&srwl->writerCount, 1) == 0) break; } // Now we're the writer, but there may be outstanding readers. // Spin until there aren't any more; new readers will wait now // that we're the writer. while (srwl->readerCount != 0) { assert(srwl->writerCount >= 0 && srwl->readerCount >= 0); YieldProcessor(); } } static void WINAPI stub_srwlock_ReleaseExclusive(MDBX_srwlock *srwl) { assert(srwl->writerCount == 1 && srwl->readerCount >= 0); srwl->writerCount = 0; } MDBX_srwlock_function mdbx_srwlock_Init, mdbx_srwlock_AcquireShared, mdbx_srwlock_ReleaseShared, mdbx_srwlock_AcquireExclusive, mdbx_srwlock_ReleaseExclusive; /*----------------------------------------------------------------------------*/ #if 0 /* LY: unused for now */ static DWORD WINAPI stub_DiscardVirtualMemory(PVOID VirtualAddress, SIZE_T Size) { return VirtualAlloc(VirtualAddress, Size, MEM_RESET, PAGE_NOACCESS) ? ERROR_SUCCESS : GetLastError(); } #endif /* unused for now */ static uint64_t WINAPI stub_GetTickCount64(void) { LARGE_INTEGER Counter, Frequency; return (QueryPerformanceFrequency(&Frequency) && QueryPerformanceCounter(&Counter)) ? Counter.QuadPart * 1000ul / Frequency.QuadPart : 0; } /*----------------------------------------------------------------------------*/ #ifndef MDBX_ALLOY MDBX_NtExtendSection mdbx_NtExtendSection; MDBX_GetFileInformationByHandleEx mdbx_GetFileInformationByHandleEx; MDBX_GetVolumeInformationByHandleW mdbx_GetVolumeInformationByHandleW; MDBX_GetFinalPathNameByHandleW mdbx_GetFinalPathNameByHandleW; MDBX_SetFileInformationByHandle mdbx_SetFileInformationByHandle; MDBX_NtFsControlFile mdbx_NtFsControlFile; MDBX_PrefetchVirtualMemory mdbx_PrefetchVirtualMemory; MDBX_GetTickCount64 mdbx_GetTickCount64; #if 0 /* LY: unused for now */ MDBX_DiscardVirtualMemory mdbx_DiscardVirtualMemory; MDBX_OfferVirtualMemory mdbx_OfferVirtualMemory; MDBX_ReclaimVirtualMemory mdbx_ReclaimVirtualMemory; #endif /* unused for now */ #endif /* MDBX_ALLOY */ static void mdbx_winnt_import(void) { const HINSTANCE hNtdll = GetModuleHandleA("ntdll.dll"); #define GET_PROC_ADDR(dll, ENTRY) \ mdbx_##ENTRY = (MDBX_##ENTRY)GetProcAddress(dll, #ENTRY) if (GetProcAddress(hNtdll, "wine_get_version")) { assert(mdbx_RunningUnderWine()); } else { GET_PROC_ADDR(hNtdll, NtFsControlFile); GET_PROC_ADDR(hNtdll, NtExtendSection); assert(!mdbx_RunningUnderWine()); } const HINSTANCE hKernel32dll = GetModuleHandleA("kernel32.dll"); GET_PROC_ADDR(hKernel32dll, GetFileInformationByHandleEx); GET_PROC_ADDR(hKernel32dll, GetTickCount64); if (!mdbx_GetTickCount64) mdbx_GetTickCount64 = stub_GetTickCount64; if (!mdbx_RunningUnderWine()) { GET_PROC_ADDR(hKernel32dll, SetFileInformationByHandle); GET_PROC_ADDR(hKernel32dll, GetVolumeInformationByHandleW); GET_PROC_ADDR(hKernel32dll, GetFinalPathNameByHandleW); GET_PROC_ADDR(hKernel32dll, PrefetchVirtualMemory); } #if 0 /* LY: unused for now */ if (!mdbx_RunningUnderWine()) { GET_PROC_ADDR(hKernel32dll, DiscardVirtualMemory); GET_PROC_ADDR(hKernel32dll, OfferVirtualMemory); GET_PROC_ADDR(hKernel32dll, ReclaimVirtualMemory); } if (!mdbx_DiscardVirtualMemory) mdbx_DiscardVirtualMemory = stub_DiscardVirtualMemory; if (!mdbx_OfferVirtualMemory) mdbx_OfferVirtualMemory = stub_OfferVirtualMemory; if (!mdbx_ReclaimVirtualMemory) mdbx_ReclaimVirtualMemory = stub_ReclaimVirtualMemory; #endif /* unused for now */ #undef GET_PROC_ADDR const MDBX_srwlock_function init = (MDBX_srwlock_function)GetProcAddress(hKernel32dll, "InitializeSRWLock"); if (init != NULL) { mdbx_srwlock_Init = init; mdbx_srwlock_AcquireShared = (MDBX_srwlock_function)GetProcAddress( hKernel32dll, "AcquireSRWLockShared"); mdbx_srwlock_ReleaseShared = (MDBX_srwlock_function)GetProcAddress( hKernel32dll, "ReleaseSRWLockShared"); mdbx_srwlock_AcquireExclusive = (MDBX_srwlock_function)GetProcAddress( hKernel32dll, "AcquireSRWLockExclusive"); mdbx_srwlock_ReleaseExclusive = (MDBX_srwlock_function)GetProcAddress( hKernel32dll, "ReleaseSRWLockExclusive"); } else { mdbx_srwlock_Init = stub_srwlock_Init; mdbx_srwlock_AcquireShared = stub_srwlock_AcquireShared; mdbx_srwlock_ReleaseShared = stub_srwlock_ReleaseShared; mdbx_srwlock_AcquireExclusive = stub_srwlock_AcquireExclusive; mdbx_srwlock_ReleaseExclusive = stub_srwlock_ReleaseExclusive; } } #endif /* Windows LCK-implementation */
the_stack_data/225707.c
/////////////////////////////////////////////////////////////////////////////// // // IMPORTANT NOTICE // // The following open source license statement does not apply to any // entity in the Exception List published by FMSoft. // // For more information, please visit: // // https://www.fmsoft.cn/exception-list // ////////////////////////////////////////////////////////////////////////////// static const unsigned char left_arrow_enable_data[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x17, 0x0, 0x0, 0x0, 0x17, 0x8, 0x6, 0x0, 0x0, 0x0, 0xe0, 0x2a, 0xd4, 0xa0, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xaf, 0xc8, 0x37, 0x5, 0x8a, 0xe9, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x0, 0x41, 0x64, 0x6f, 0x62, 0x65, 0x20, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x52, 0x65, 0x61, 0x64, 0x79, 0x71, 0xc9, 0x65, 0x3c, 0x0, 0x0, 0x3, 0x77, 0x49, 0x44, 0x41, 0x54, 0x78, 0xda, 0x94, 0x96, 0xcb, 0x4f, 0x13, 0x51, 0x14, 0xc6, 0xcf, 0x9d, 0xe, 0xd3, 0x29, 0xa5, 0x60, 0xa1, 0xf, 0xa0, 0x20, 0x8, 0xe5, 0x25, 0x4, 0x9, 0x89, 0x8f, 0xc4, 0xc4, 0xa8, 0x1b, 0x5d, 0xa3, 0x31, 0x71, 0xa9, 0x3b, 0x75, 0xed, 0xd2, 0x98, 0xb8, 0x33, 0xc1, 0x3f, 0x80, 0xbd, 0x71, 0x61, 0x8c, 0x89, 0x2b, 0x13, 0x4c, 0xc, 0x89, 0x46, 0x51, 0x5e, 0x9a, 0xa8, 0xf8, 0x80, 0x40, 0x9, 0x4a, 0x41, 0x29, 0x14, 0xe8, 0x94, 0x76, 0xee, 0xcc, 0xf5, 0xdc, 0xe6, 0xc, 0x96, 0x62, 0x2d, 0x36, 0xf9, 0x25, 0x33, 0xed, 0xcc, 0x77, 0xbf, 0x7b, 0xce, 0xbd, 0xdf, 0x2d, 0x83, 0x45, 0x1, 0xfb, 0xfc, 0x30, 0xc4, 0x45, 0xa8, 0x88, 0x82, 0xd8, 0x88, 0x85, 0x70, 0xba, 0xb6, 0xf3, 0x5f, 0x50, 0xff, 0x43, 0x54, 0x43, 0xbc, 0x48, 0x5, 0x52, 0x4e, 0xf7, 0x52, 0x38, 0x83, 0x18, 0x44, 0x1a, 0xc9, 0xd2, 0xf7, 0xa2, 0x94, 0xb8, 0x14, 0x2d, 0x23, 0xd1, 0x6a, 0x24, 0x88, 0xd4, 0xd2, 0xb5, 0x4e, 0x4e, 0x37, 0x90, 0x55, 0x64, 0x5, 0x59, 0x46, 0x92, 0x34, 0x8, 0x2f, 0x26, 0xae, 0x90, 0xa8, 0x7, 0xa9, 0x42, 0xc2, 0x48, 0x13, 0xd2, 0x82, 0xb4, 0x22, 0x75, 0x34, 0x3, 0x9b, 0x44, 0x63, 0xc8, 0x57, 0x64, 0x9a, 0xde, 0xb7, 0xfe, 0x26, 0xee, 0x94, 0x40, 0xba, 0xf2, 0x91, 0xd3, 0x6, 0xa4, 0xd, 0x39, 0x8c, 0xb4, 0xb7, 0x30, 0xcb, 0x7d, 0xd7, 0x93, 0x6d, 0xe9, 0x57, 0x45, 0xd5, 0xeb, 0xc4, 0xe6, 0xe6, 0x8d, 0x58, 0x62, 0x3e, 0x19, 0x8a, 0x44, 0xc0, 0x5b, 0x11, 0x4, 0x45, 0x91, 0xb5, 0x4f, 0x21, 0x5b, 0xb2, 0x4c, 0x6a, 0x41, 0x9, 0xb4, 0xbc, 0x12, 0xd4, 0x23, 0x51, 0xa4, 0x3, 0xe9, 0xd5, 0x19, 0xe8, 0xb7, 0xca, 0xd2, 0x8d, 0xd7, 0xca, 0xed, 0x83, 0x1e, 0x45, 0x71, 0x49, 0x1f, 0x17, 0x42, 0x95, 0xfa, 0xbb, 0x37, 0xa3, 0xca, 0xe0, 0x72, 0x7c, 0x1e, 0xfa, 0x8e, 0x45, 0xa1, 0xdc, 0x3b, 0x8b, 0xcf, 0xce, 0x91, 0xe, 0x53, 0xf3, 0x84, 0xa5, 0xdb, 0x4a, 0x24, 0x82, 0x1c, 0x42, 0x3a, 0xa5, 0x28, 0x12, 0xb8, 0xc4, 0xd2, 0x81, 0x3b, 0x1e, 0x33, 0x1a, 0x51, 0x99, 0x2e, 0xb, 0xc1, 0xed, 0x3f, 0x8b, 0xe2, 0xc0, 0xaf, 0xa5, 0xa, 0x58, 0xf8, 0xe8, 0x83, 0xa6, 0xd6, 0xc, 0x8a, 0x7, 0xa8, 0x5c, 0xaa, 0xb3, 0x5a, 0x18, 0xd5, 0x57, 0xa, 0x37, 0x22, 0x3d, 0x48, 0x3f, 0xd2, 0xdd, 0xd, 0x66, 0xf9, 0xa0, 0xb2, 0xd1, 0x76, 0x42, 0x57, 0xfc, 0xf2, 0x61, 0xce, 0xf7, 0x36, 0x87, 0x6f, 0x6d, 0xba, 0x60, 0x25, 0xae, 0x81, 0x91, 0x52, 0x68, 0xd6, 0x1a, 0xf5, 0x8c, 0x39, 0xe2, 0xd2, 0x75, 0xd, 0xd5, 0xf6, 0x78, 0xa5, 0xb0, 0xba, 0x6e, 0x43, 0xb2, 0xf9, 0xb2, 0xc6, 0x1b, 0xca, 0x18, 0x63, 0x9c, 0xdb, 0x45, 0x97, 0x93, 0x90, 0xb3, 0xb0, 0x2d, 0x86, 0x17, 0x8c, 0xb4, 0x76, 0x70, 0xc4, 0xdd, 0x24, 0x7e, 0x28, 0x28, 0x78, 0xf7, 0x13, 0x7b, 0xa5, 0xaf, 0x59, 0x45, 0x17, 0xe8, 0xd4, 0x2c, 0xb1, 0x56, 0x2d, 0xcb, 0x2a, 0x5c, 0x10, 0xe, 0x3b, 0x65, 0xd1, 0x68, 0x75, 0x84, 0x2f, 0x66, 0xd7, 0x42, 0xd, 0x2e, 0xd3, 0xcb, 0xcd, 0xfd, 0x6d, 0x5b, 0xdb, 0x2e, 0x3e, 0xab, 0xc2, 0xd5, 0xa2, 0xbe, 0x4f, 0x73, 0x23, 0xeb, 0x36, 0x85, 0x82, 0xe5, 0xd8, 0x8f, 0x78, 0x81, 0xf3, 0x3d, 0x9b, 0x45, 0x50, 0x36, 0xc8, 0x5d, 0xb5, 0xf9, 0x8a, 0xe9, 0x1b, 0xd7, 0xc7, 0xa7, 0x63, 0x8b, 0x2b, 0x3f, 0x6d, 0x8e, 0x1d, 0x2c, 0xc5, 0xbf, 0x9c, 0x3b, 0xe1, 0x93, 0xa5, 0x6d, 0xfb, 0x3, 0xbc, 0x3e, 0x6b, 0xb8, 0x36, 0x1a, 0x3f, 0x37, 0xfc, 0x7a, 0x66, 0xe8, 0xe9, 0x33, 0x23, 0x65, 0x18, 0x39, 0x77, 0xc5, 0x10, 0x25, 0xc4, 0x5, 0xb9, 0xfe, 0x99, 0xdb, 0x0, 0xaa, 0x3a, 0x9, 0x4d, 0x2d, 0x99, 0xf4, 0xf9, 0x81, 0x5f, 0xf7, 0x2a, 0xea, 0xbf, 0xd, 0xdc, 0x7f, 0xfc, 0x7d, 0x64, 0x62, 0xca, 0x2c, 0x26, 0x6e, 0x8b, 0x5d, 0xa9, 0x2a, 0x88, 0x5d, 0x35, 0x77, 0x9c, 0xcf, 0xe7, 0x36, 0x81, 0xe6, 0x76, 0x41, 0xe4, 0xe0, 0x11, 0xf0, 0xd7, 0xf0, 0xb9, 0xa6, 0xd6, 0xed, 0x6b, 0x93, 0xa3, 0xc9, 0xd3, 0x9f, 0x1e, 0x85, 0x6f, 0x9e, 0x39, 0xe9, 0x6f, 0xc, 0x87, 0x95, 0x7c, 0xb5, 0x74, 0x6, 0x43, 0x31, 0xd7, 0x1e, 0x26, 0xf2, 0xc4, 0x45, 0x7e, 0x2a, 0x5a, 0x94, 0x7, 0x4b, 0x74, 0xbf, 0x8d, 0x2f, 0xac, 0x62, 0x5e, 0xf4, 0x40, 0x47, 0x4f, 0x18, 0xc2, 0xf5, 0xe6, 0xc8, 0xcc, 0xb4, 0xf1, 0xea, 0xf9, 0xcb, 0xc4, 0x95, 0xaa, 0xb2, 0xba, 0xab, 0x67, 0x4f, 0x79, 0x3d, 0xba, 0xce, 0xc, 0x2c, 0xd9, 0x8b, 0xf1, 0x49, 0xe, 0xdd, 0x47, 0x2d, 0x70, 0xbb, 0x5, 0x99, 0xe4, 0xa4, 0xb7, 0xe3, 0x5c, 0xe4, 0xb9, 0x77, 0x9a, 0x2b, 0x63, 0x74, 0x1, 0x5c, 0xae, 0x76, 0xa8, 0x9, 0x76, 0x80, 0xaf, 0x32, 0x90, 0x6d, 0x68, 0xce, 0xe, 0x7d, 0x98, 0x4a, 0x3d, 0x7c, 0xf0, 0xc4, 0xdf, 0x9b, 0x5e, 0xf7, 0x8f, 0x8d, 0x8d, 0x31, 0x23, 0x58, 0x97, 0x82, 0xce, 0x9e, 0x14, 0x54, 0xf9, 0xa5, 0xe0, 0x3a, 0xe5, 0xba, 0xd4, 0x10, 0xac, 0xe0, 0x24, 0x2a, 0x4c, 0xc5, 0x6a, 0xca, 0x6f, 0x19, 0xb7, 0x5d, 0x32, 0x12, 0x70, 0x9b, 0x7b, 0x61, 0x31, 0xa6, 0xc1, 0xec, 0x67, 0xf, 0xac, 0xad, 0xaa, 0x10, 0xaa, 0x33, 0xa1, 0xab, 0xd7, 0xc0, 0xd9, 0x25, 0xb0, 0x5f, 0x4f, 0xf1, 0x99, 0xb7, 0xc8, 0x8c, 0x34, 0xca, 0x8a, 0x1c, 0x73, 0x8c, 0x66, 0xa5, 0x53, 0x10, 0x55, 0xd3, 0x0, 0xd1, 0xdc, 0x20, 0x42, 0x74, 0x42, 0x66, 0x5b, 0x1, 0xd3, 0x64, 0xa0, 0x69, 0x2, 0x7b, 0x94, 0xc4, 0x32, 0x4e, 0x90, 0xf0, 0x17, 0x24, 0x2e, 0x67, 0xc0, 0x4a, 0x9c, 0xa1, 0xf9, 0x83, 0xc8, 0xf0, 0xa, 0x51, 0xb8, 0xc9, 0x8c, 0xf, 0x50, 0x6c, 0xa4, 0xe9, 0x4, 0x8a, 0xd1, 0x82, 0x58, 0xa6, 0xd3, 0x89, 0x97, 0x3a, 0xe6, 0xe4, 0xc8, 0x26, 0x35, 0xc8, 0xa4, 0x83, 0x20, 0x41, 0x42, 0x3e, 0x1a, 0xd8, 0xa4, 0xc5, 0xb0, 0x4e, 0xa4, 0xa, 0x1b, 0x5a, 0x32, 0x42, 0xe8, 0x20, 0x76, 0x9a, 0x9d, 0x28, 0xf8, 0x7, 0xc0, 0xe9, 0x77, 0xc7, 0x48, 0xae, 0x1c, 0xbf, 0x5, 0x18, 0x0, 0xaa, 0xe0, 0x83, 0xb5, 0x7f, 0x28, 0x11, 0xeb, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, };
the_stack_data/64091.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> char filename[128], outfolder[64], command[96], rnum[8]; int i; FILE * fh; int main(int argc, char * argv[]){ printf("fakeBinning_refiner run\n"); printf("received %d parameters\n" , argc); for( i = 0; i < argc; i++ ){ printf(" param %d: %s\n", i, argv[i]); } srand(time(NULL)); if( argc == 6 && strcmp(argv[3], "-p") == 0 ){ strcpy(outfolder, argv[4]); strcat(outfolder, "_Binning_refiner_outputs/"); strcpy(command, "mkdir "); strcat(command, outfolder); system(command); strcpy(filename, outfolder); strcat(filename, argv[4]); strcat(filename, "_sources_and_length.txt"); fh = fopen(filename, "w"); fprintf(fh, "%s content\n", filename); fclose(fh); strcpy(filename, outfolder); strcat(filename, argv[4]); strcat(filename, "_contigs.txt"); fh = fopen(filename, "w"); fprintf(fh, "%s content\n", filename); fclose(fh); strcpy(filename, outfolder); strcat(filename, argv[4]); strcat(filename, "_sankey.csv"); fh = fopen(filename, "w"); fprintf(fh, "%s content\n", filename); fclose(fh); strcpy(filename, outfolder); strcat(filename, argv[4]); strcat(filename, "_sankey.html"); fh = fopen(filename, "w"); fprintf(fh, "<html><head><title>sankey</title></head><body>%s content</body></html>\n", filename); fclose(fh); strcat(outfolder, argv[4]); strcat(outfolder, "_refined_bins/"); strcpy(command, "mkdir "); strcat(command, outfolder); system(command); for( i = 0; i < 6; i++ ){ strcpy(filename, outfolder); strcat(filename, "refined_"); sprintf(rnum, "%04d", rand() % 10000); strcat(filename, rnum); strcat(filename, ".fabin"); fh = fopen(filename, "w"); fprintf(fh, "%s content\n", filename); fclose(fh); } printf("outputs were made\n"); }else{ printf("Received bad number of parameters: %d\n", argc); } return 0; }
the_stack_data/1113579.c
/* Copyright (C) 2013-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <string.h> int main (void) { FILE *f; int lost = 0; int c; double d; char s[] = "+.e"; f = fmemopen (s, strlen (s), "r"); /* This should fail to parse a floating-point number, and leave 'e' in the input. */ lost |= (fscanf (f, "%lf", &d) != 0); c = fgetc (f); lost |= c != 'e'; puts (lost ? "Test FAILED!" : "Test succeeded."); return lost; }
the_stack_data/117327703.c
/* Copyright (C) 2011-2017 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Chris Metcalf <[email protected]>, 2011. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */ #include <unistd.h> #include <fcntl.h> #include <sys/param.h> #ifdef HAVE_INLINED_SYSCALLS # include <errno.h> # include <sysdep.h> #endif ssize_t __readlink_chk (const char *path, void *buf, size_t len, size_t buflen) { if (len > buflen) __chk_fail (); #ifdef HAVE_INLINED_SYSCALLS return INLINE_SYSCALL (readlinkat, 4, AT_FDCWD, path, buf, len); #else return __readlink (path, buf, len); #endif }
the_stack_data/165767234.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <fcntl.h> int main (int argc, char **argv){ int fd0 = open ("stdin.txt" , O_CREAT | O_RDONLY, 0666); int fd1 = open ("stdout.txt", O_CREAT | O_WRONLY, 0666); int fd2 = open ("stderr.txt", O_CREAT | O_WRONLY, 0666); dup2 (fd0, STDIN_FILENO); dup2 (fd1, STDOUT_FILENO); dup2 (fd2, STDERR_FILENO); int rd; char buf[10]; while ((rd = read (STDIN_FILENO, buf, 10))){ write (STDOUT_FILENO, buf, rd); write (STDERR_FILENO, buf, rd); } exit(0); close (fd0); close (fd1); close (fd2); return 0; }
the_stack_data/192329904.c
/* Solution for Day 7 of the 2016 Advent of Code */ /* Solution by Andrew Fugier */ #include <stdio.h> #include <stdlib.h> #include <string.h> struct node { char v[3]; // ABA or BAB types struct node* next; // next node }; void list_init(struct node *list){ list->next=NULL; } void list_print(struct node *list){ printf("LIST: "); while(list->next != NULL){ printf("%c%c%c,", list->v[0], list->v[1], list->v[2]); list = list->next; } printf(" (END)\n"); } void list_add(char *s, struct node *ll){ while(ll->next != NULL){ ll = ll->next; } ll->next = malloc(sizeof(struct node)); ll->v[0] = s[0]; ll->v[1] = s[1]; ll->v[2] = s[2]; ll->next->next = NULL; } int list_find(char *s, struct node *ll){ // FIND THE INVERSE (ABA->BAB) in LL while(ll->next != NULL){ if(ll->v[0] == s[1] && ll->v[1] == s[0] && ll->v[2] == s[1]){ return 1; } ll = ll->next; } return 0; } void find_seq(char *s, struct node *list){ // checks for ABA or BAB seq // loop though string, checking for the ABBA seq // [0|1|2] verify non-NULL, 0!=1, 0==2 // ^ pointer int i = 0; while(s[i]+1 != '\0' && s[i+2] != '\0'){ if((s[i] != s[i+1]) && (s[i]==s[i+2])){ list_add(s+i, list); } i++; } } int main() { FILE *fp = fopen("input", "r"); char data[512]; // no line would be more than this, right? int valid_ip = 0; if(fp == NULL) { printf("could not open input file\n"); return -1; } while (fscanf(fp, "%s", data) != EOF) { int i = 0, in_hypernet = 0; char *s = data; struct node list_addr, list_net; list_init(&list_addr); list_init(&list_net); while(data[++i]){ // parse each substring if(data[i] == '[' || data[i] == ']' || data[i+1] == '\0'){ if(data[i+1]){ data[i] = '\0'; } // set null term if ! EOL if(in_hypernet){ find_seq(s, &list_net); } else{ find_seq(s, &list_addr); } in_hypernet = !in_hypernet; s = data + i + 1; // set for start of next string } } if(list_addr.next != NULL && list_net.next != NULL){ int f = 0; do{ f = list_find(list_addr.v, &list_net); valid_ip = valid_ip + f; list_addr = *list_addr.next; }while (list_addr.next != NULL && !f); } } printf("There are %i valid IPv7 addrs\n", valid_ip); fclose(fp); // fp should be valid as we return -1 above we fail to open return(0); }
the_stack_data/123824.c
#include <stdio.h> int main() { int i,a,n,t,sum=0; printf("input a and n:"); scanf("%d%d",&a,&n); for(t=0,i=1;i<=n;i++) { t=t*10+a; if(i==1) printf("Sn=%d ",t); else printf("+ %d",t); sum+=t; } printf(" = %d\n",sum); return 0; }
the_stack_data/65319.c
void rotate(int** matrix, int matrixRowSize, int matrixColSize) { int x, y, t; for (y = 0; y < matrixRowSize/2; y++) { for (x = 0; x < matrixColSize; x++) { t = *(*(matrix + y) + x); *(*(matrix + y) + x) = *(*(matrix + matrixRowSize-1-y) + x); *(*(matrix + matrixRowSize-1-y) + x) = t; } } for (y = 0; y < matrixRowSize; y++) { for (x = y+1; x < matrixColSize; x++) { t = *(*(matrix + y) + x); *(*(matrix + y) + x) = *(*(matrix + x) + y); *(*(matrix + x) + y) = t; } } }
the_stack_data/76699341.c
/* ** EPITECH PROJECT, 2017 ** C_Object ** File description: ** vector_errors.c */ #include <stdio.h> #include <stdlib.h> static const char *class_type = "vector"; void throw_vector(char const *msg) { fprintf(stderr, "%s : %s\n", class_type, msg); abort(); } void throw_vector_elem(int n) { fprintf(stderr, "%s : access elem %d impossible\n", class_type, n); abort(); }
the_stack_data/173578515.c
#include <stdio.h> // int main() { int mat[4][4],lin,col; printf ("\nDigite valor para os elementos da matriz\n"); for (lin=0;lin<4;lin++) for (col=0;col<4;col++) if (lin==col) //SE linha for igual coluna { printf ("Elemento[%d][%d] = 0 \n",lin,col); //>> ENTÃO valor será igual a zero mat[lin][col]=0; } else //>> SENÃO { printf ("Elemento[%d][%d] = ",lin,col); //>> valor será atribuído pelo usuário na variavel scanf ("%d",&mat[lin][col]) ; } printf ("\nListagem dos elementos da matriz\n"); for (lin=0;lin<4;lin++) for (col=0;col<4;col++) printf("\nElemento[%d][%d] = %d",lin,col,mat[lin][col]); }
the_stack_data/82950430.c
#include <stdio.h> #include <stdlib.h> int main() { int f, l, n, rem, sum; printf("Enter the range\n"); scanf("%d %d",&f,&l); while(f<=l) { sum=0; n=f; while(n>0) { rem=n%10; sum=sum+(rem*rem*rem); n=n/10; } if(f==sum) { printf("%d is an Armstrong Number\n",f); } else { printf("%d is not an Armstrong Number\n",f); } f++; } return 0; }
the_stack_data/835623.c
// C program to implement Runge // Kutta method #include <stdio.h> // A sample differential equation // "dy/dx = (x - y)/2" float dydx(float x, float y) { return (x + y - 2); } // Finds value of y for a given x // using step size h // and initial value y0 at x0. float rungeKutta(float x0, float y0, float x, float h) { // Count number of iterations // using step size or // step height h int n = (int)((x - x0) / h); float k1, k2; // Iterate for number of iterations float y = y0; for (int i = 1; i <= n; i++) { // Apply Runge Kutta Formulas // to find next value of y k1 = h * dydx(x0, y); k2 = h * dydx(x0 + 0.5 * h, y + 0.5 * k1); // Update next value of y y = y + (1.0 / 6.0) * (k1 + 2 * k2); // Update next value of x x0 = x0 + h; } return y; } // Driver Code int main() { float x0 = 0, y = 1, x = 2, h = 0.2; printf("y(x) = %f", rungeKutta(x0, y, x, h)); return 0; }
the_stack_data/361725.c
// Your app here
the_stack_data/14199341.c
#include <stdlib.h> #include <stdio.h> struct Node { int data; struct Node *next; }; void print_list(struct Node **head) { struct Node *n = *head; fprintf(stdout, "{"); while (n) { fprintf(stdout, "%d, ", n->data); n = n->next; } fprintf(stdout, "\b\b}\n"); } struct Node *node_new(int data) { struct Node *ret = NULL; ret = malloc(sizeof(struct Node)); if (!ret) { perror("Failed to malloc \"ret\" in \"node_new()\". Try downloading more RAM.\n"); return NULL; } ret->data = data; ret->next = NULL; return ret; } struct Node *add_node(struct Node **head, int data) { struct Node *ret = node_new(data); struct Node *n = *head; if (!*head) { *head = ret; return ret; } while (n->next) { n = n->next; } n->next = ret; return ret; } void delete_list(struct Node **head) { struct Node *n = *head, *next = NULL; while (n) { next = n->next; free(n); n = next; } } struct Node *list_from_arr(int arr[], int size) { struct Node *ret; if (0 < size) { ret = node_new(arr[0]); } for (int i = 1; i < size; i++) { add_node(&ret, arr[i]); } return ret; } struct Node *list_no_duplicates_old(struct Node *head) { struct Node *ret = NULL, *n = head; int data; while (n) { data = n->data; if ((n->next) && (n->next->data == data)) { while ((n->next) && (n->next->data == data)) { n = n->next; } } else { add_node(&ret, data); } n = n->next; } return ret; } struct Node *list_no_duplicates(struct Node *head) { struct Node *n = head, *n_prev = NULL; int data; while (n) { data = n->data; if (n->next && (n->next->data == data)) { struct Node *d = n, *d_next = NULL; while (d && (d->data == data)) { d_next = d->next; free(d); d = d_next; } if (n_prev) { n = n_prev; n->next = d; } else { head = d; n = d; n_prev = NULL; } } else { n_prev = n; n = n->next; } } return head; } int main(int argc, char *argv[]) { int arr[] = {1, 1, 1, 2, 3}; struct Node *head = list_from_arr(arr, 5); print_list(&head); head = list_no_duplicates(head); print_list(&head); delete_list(&head); return EXIT_SUCCESS; }
the_stack_data/90766069.c
/* This testcase is part of GDB, the GNU debugger. Copyright 2010-2020 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ extern void jumper (void (*jumpto) (void)); static void func (void) { volatile int c; c = 5; c = 10; /* watchpoint-here */ c = 20; } int main (void) { jumper (func); return 0; }
the_stack_data/106231.c
/* Author : Rakesh Malik * Date : 16.05.2011 * Subject : Newton's Backward Interpolation Formula * Assignment no. : 15 */ #include<stdio.h> double newton_Backward_interpolation(double,double[],double[],int); int fact(int); int main() { int n,i; double x[100],fx[100],X,fX; printf("Enter number of data : "); scanf("%d",&n); for(i=0;i<n;i++) { printf("Enter value of x%d : ",i+1); scanf("%lf",&x[i]); printf("Enter value of f(x%d) : ",i+1); scanf("%lf",&fx[i]); } printf("\n\n x :\t"); for(i=0;i<n;i++) printf("%g\t",x[i]); printf("\n f(x) :\t"); for(i=0;i<n;i++) printf("%g\t",fx[i]); printf("\n\nEnter value of x : "); scanf("%lf",&X); fX=newton_Backward_interpolation(X,x,fx,n); printf("\n\nUsing Newton's Backward interpolation method :\n\tf(x)=f(%g)=%g",X,fX); printf("\n"); } double newton_Backward_interpolation(double X,double x[],double fx[],int n) { double fX,h,u,temp; int i,j; h=x[1]-x[0]; u=(X-x[n-1])/h; printf("\n\nx=%g, xn=%g, h=%g",X,x[n-1],h); printf("\n\nu=(x-xn)/h=(%g-%g)/%g=%g",X,x[n-1],h,u); printf("\n\nForward differance table : \n f(x) :\t"); for(i=0;i<n;i++) printf("%g\t",fx[i]); for(fX=i=0;i<n;i++) { temp=fx[n-1-i]/fact((int)i); for(j=0;j<i;j++) temp*=(u+j); fX+=temp; printf("\nFD%df(x) :\t",i); for(j=0;j<n-i-1;j++) { fx[j]=fx[j+1]-fx[j]; printf("%g\t",fx[j]); } } return fX; } int fact(int n) { int x=1; for(;n>1;n--) x*=n; return x; }
the_stack_data/86884.c
#ifdef STM32F0xx #include "stm32f0xx_hal_crc.c" #endif #ifdef STM32F1xx #include "stm32f1xx_hal_crc.c" #endif #ifdef STM32F2xx #include "stm32f2xx_hal_crc.c" #endif #ifdef STM32F3xx #include "stm32f3xx_hal_crc.c" #endif #ifdef STM32F4xx #include "stm32f4xx_hal_crc.c" #endif #ifdef STM32F7xx #include "stm32f7xx_hal_crc.c" #endif #ifdef STM32G0xx #include "stm32g0xx_hal_crc.c" #endif #ifdef STM32G4xx #include "stm32g4xx_hal_crc.c" #endif #ifdef STM32H7xx #include "stm32h7xx_hal_crc.c" #endif #ifdef STM32L0xx #include "stm32l0xx_hal_crc.c" #endif #ifdef STM32L1xx #include "stm32l1xx_hal_crc.c" #endif #ifdef STM32L4xx #include "stm32l4xx_hal_crc.c" #endif #ifdef STM32WBxx #include "stm32wbxx_hal_crc.c" #endif
the_stack_data/121577.c
// Trabalhando com erros // Bibliotecas #include <stdio.h> #include <errno.h> #include <string.h> #include <stdlib.h> // Cria variavel para os erros extern int errno; // Funcao principal int main(int argc, char const *argv[]) { FILE *file = fopen("nothing.txt", "r"); if (file == NULL) { perror("Falha"); char *errorString = strerror(errno); fprintf(stderr, "<Falha> %s\n", errorString); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); puts("final"); return 0; }
the_stack_data/1186662.c
/*numPass=7, numTotal=7 Verdict:ACCEPTED, Visibility:1, Input:"1 4 5", ExpOutput:"1111 1 1 1 1 1 1 1111 ", Output:"1111 1 1 1 1 1 1 1111 " Verdict:ACCEPTED, Visibility:1, Input:"2 5 6", ExpOutput:"22222 2 2 2 2 2 2 2 2 22222 ", Output:"22222 2 2 2 2 2 2 2 2 22222 " Verdict:ACCEPTED, Visibility:1, Input:"9 6 7", ExpOutput:"999999 9 9 9 9 9 9 9 9 9 9 999999 ", Output:"999999 9 9 9 9 9 9 9 9 9 9 999999 " Verdict:ACCEPTED, Visibility:1, Input:"3 4 5", ExpOutput:"3333 3 3 3 3 3 3 3333 ", Output:"3333 3 3 3 3 3 3 3333 " Verdict:ACCEPTED, Visibility:1, Input:"2 2 2", ExpOutput:"22 22 ", Output:"22 22 " Verdict:ACCEPTED, Visibility:0, Input:"3 3 3", ExpOutput:"333 3 3 333 ", Output:"333 3 3 333 " Verdict:ACCEPTED, Visibility:0, Input:"1 1 1", ExpOutput:"1 ", Output:"1 " */ #include<stdio.h> int main() { int a,b,c; scanf("%d%d%d",&a,&b,&c); int i,j; for(i=0;i<c;i++){ for(j=0;j<b;j++){ if (i==0||i==c-1||j==0||j==b-1){ printf("%d",a); } else{ printf(" "); } } printf("\n"); } return 0; }
the_stack_data/10544.c
/***************************************************************************** * * \file * * \brief Basic SMTP Client for AVR32 UC3. * * Copyright (c) 2009-2014 Atmel Corporation. All rights reserved. * * \asf_license_start * * \page License * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 3. The name of Atmel may not be used to endorse or promote products derived * from this software without specific prior written permission. * * 4. This software may only be redistributed and used in connection with an * Atmel microcontroller product. * * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * \asf_license_stop * *****************************************************************************/ /* Implements a simplistic SMTP client. First time the task is started, connection is made and email is sent. Mail flag is then reset. Each time you press the Push Button 0, a new mail will be sent. */ /** * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> */ #if (SMTP_USED == 1) #include <string.h> // Scheduler includes. #include "FreeRTOS.h" #include "task.h" #include "BasicSMTP.h" // Demo includes. #include "portmacro.h" #include "partest.h" #include "intc.h" #include "gpio.h" // lwIP includes. #include "lwip/api.h" #include "lwip/tcpip.h" #include "lwip/memp.h" #include "lwip/stats.h" #include "lwip/opt.h" #include "lwip/api.h" #include "lwip/arch.h" #include "lwip/sys.h" #include "lwip/sockets.h" #include "lwip/init.h" #if ( (LWIP_VERSION) == ((1U << 24) | (3U << 16) | (2U << 8) | (LWIP_VERSION_RC)) ) #include "netif/loopif.h" #endif //! SMTP default port #define SMTP_PORT 25 //! SMTP EHLO code answer #define SMTP_EHLO_STRING "220" //! SMTP end of transmission code answer #define SMTP_END_OF_TRANSMISSION_STRING "221" //! SMTP OK code answer #define SMTP_OK_STRING "250" //! SMTP start of transmission code answer #define SMTP_START_OF_TRANSMISSION_STRING "354" //! SMTP DATA<CRLF> #define SMTP_DATA_STRING "DATA\r\n" //! SMTP <CRLF>.<CRLF> #define SMTP_MAIL_END_STRING "\r\n.\r\n" //! SMTP QUIT<CRLFCRLF> #define SMTP_QUIT_STRING "QUIT\r\n" //! Server address #error configure SMTP server address portCHAR cServer[] = "192.168.0.1"; //! Fill here the mailfrom with your mail address #error configure SMTP mail sender char cMailfrom[] = "MAIL FROM: <[email protected]>\r\n"; //! Fill here the mailto with your contact mail address #error configure SMTP mail recipient char cMailto[] = "RCPT TO: <[email protected]>\r\n"; //! Fill here the mailcontent with the mail you want to send #error configure SMTP mail content char cMailcontent[] ="Subject: *** SPAM ***\r\nFROM: \"Your Name here\" <[email protected]>\r\nTO: \"Your Contact here\" <[email protected]>\r\n\r\nSay what you want here."; //! flag to send mail bool bSendMail = pdFALSE; //! buffer for SMTP response portCHAR cTempBuffer[200]; //_____ D E C L A R A T I O N S ____________________________________________ //! interrupt handler. #if __GNUC__ __attribute__((__naked__)) #elif __ICCAVR32__ #pragma shadow_registers = full // Naked. #endif void vpushb_ISR( void ); //! soft interrupt handler. where treatment should be done #if __GNUC__ __attribute__((__noinline__)) #endif static portBASE_TYPE prvpushb_ISR_NonNakedBehaviour( void ); //! Basic SMTP client task definition portTASK_FUNCTION( vBasicSMTPClient, pvParameters ) { struct sockaddr_in stServeurSockAddr; portLONG lRetval; portLONG lSocket = -1; // configure push button 0 to produce IT on falling edge gpio_enable_pin_interrupt(GPIO_PUSH_BUTTON_0 , GPIO_FALLING_EDGE); // Disable all interrupts vPortEnterCritical(); // register push button 0 handler on level 3 INTC_register_interrupt( (__int_handler)&vpushb_ISR, AVR32_GPIO_IRQ_0 + (GPIO_PUSH_BUTTON_0/8), AVR32_INTC_INT3); // Enable all interrupts vPortExitCritical(); for (;;) { // wait for a signal to send a mail while (bSendMail != pdTRUE) vTaskDelay(200); // Disable all interrupts vPortEnterCritical(); // clear the flag bSendMail = pdFALSE; // Enable all interrupts vPortExitCritical(); // clear the LED vParTestSetLED( 3 , pdFALSE ); // Set up port memset(&stServeurSockAddr, 0, sizeof(stServeurSockAddr)); stServeurSockAddr.sin_len = sizeof(stServeurSockAddr); stServeurSockAddr.sin_addr.s_addr = inet_addr(cServer); stServeurSockAddr.sin_port = htons(SMTP_PORT); stServeurSockAddr.sin_family = AF_INET; // socket as a stream if ( (lSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) { // socket failed, blink a LED and stay here for (;;) { vParTestToggleLED( 4 ); vTaskDelay( 200 ); } } // connect to the server if(connect(lSocket,(struct sockaddr *)&stServeurSockAddr, sizeof(stServeurSockAddr)) < 0) { // connect failed, blink a LED and stay here for (;;) { vParTestToggleLED( 6 ); vTaskDelay( 200 ); } } else { //Server: 220 SMTP Ready // wait for SMTP Server answer do { lRetval = recv(lSocket, cTempBuffer, sizeof(cTempBuffer), 0); }while (lRetval <= 0); if (strncmp(cTempBuffer, SMTP_EHLO_STRING, sizeof(cTempBuffer)) >= 0) { //Client: EHLO smtp.domain.com // send ehlo send(lSocket, "HELO ", 5, 0); send(lSocket, cServer, strlen(cServer), 0); send(lSocket, "\r\n", 2, 0); //Server: 250 // wait for SMTP Server answer do { lRetval = recv(lSocket, cTempBuffer, sizeof(cTempBuffer), 0); }while (lRetval <= 0); if (strncmp(cTempBuffer, SMTP_OK_STRING, sizeof(cTempBuffer)) >= 0) { //Client: MAIL FROM:<[email protected]> // send MAIL FROM send(lSocket, cMailfrom, strlen(cMailfrom), 0); //Server: 250 OK // wait for SMTP Server answer do { lRetval = recv(lSocket, cTempBuffer, sizeof(cTempBuffer), 0); }while (lRetval <= 0); if (strncmp(cTempBuffer, SMTP_OK_STRING, sizeof(cTempBuffer)) >= 0) { //Client: RCPT TO:<[email protected]> // send RCPT TO send(lSocket, cMailto, strlen(cMailto), 0); //Server: 250 OK // wait for SMTP Server answer do { lRetval = recv(lSocket, cTempBuffer, sizeof(cTempBuffer), 0); }while (lRetval <= 0); if (strncmp(cTempBuffer, SMTP_OK_STRING, sizeof(cTempBuffer)) >= 0) { //Client: DATA<CRLF> // send DATA send(lSocket, SMTP_DATA_STRING, 6, 0); //Server: 354 Start mail input; end with <CRLF>.<CRLF> // wait for SMTP Server answer do { lRetval = recv(lSocket, cTempBuffer, sizeof(cTempBuffer), 0); }while (lRetval <= 0); if (strncmp(cTempBuffer, SMTP_START_OF_TRANSMISSION_STRING, sizeof(cTempBuffer)) >= 0) { // send content send(lSocket, cMailcontent, strlen(cMailcontent), 0); //Client: <CRLF>.<CRLF> // send "<CRLF>.<CRLF>" send(lSocket, SMTP_MAIL_END_STRING, 5, 0); //Server: 250 OK // wait for SMTP Server answer do { lRetval = recv(lSocket, cTempBuffer, sizeof(cTempBuffer), 0); }while (lRetval <= 0); if (strncmp(cTempBuffer, SMTP_OK_STRING, sizeof(cTempBuffer)) >= 0) { //Client: QUIT<CRLFCRLF> // send QUIT send(lSocket, SMTP_QUIT_STRING, 8, 0); //Server: 221 smtp.domain.com closing transmission do { lRetval = recv(lSocket, cTempBuffer, sizeof(cTempBuffer), 0); }while (lRetval <= 0); if (strncmp(cTempBuffer, SMTP_END_OF_TRANSMISSION_STRING, sizeof(cTempBuffer)) >= 0) { vParTestSetLED( 3 , pdTRUE ); } } } } } } // close socket close(lSocket); } } } } /*! \brief push button naked interrupt handler. * */ #if __GNUC__ __attribute__((__naked__)) #elif __ICCAVR32__ #pragma shadow_registers = full // Naked. #endif void vpushb_ISR( void ) { /* This ISR can cause a context switch, so the first statement must be a call to the portENTER_SWITCHING_ISR() macro. This must be BEFORE any variable declarations. */ portENTER_SWITCHING_ISR(); prvpushb_ISR_NonNakedBehaviour(); portEXIT_SWITCHING_ISR(); } /*! \brief push button interrupt handler. Here, declarations should be done * */ #if __GNUC__ __attribute__((__noinline__)) #elif __ICCAVR32__ #pragma optimize = no_inline #endif static portBASE_TYPE prvpushb_ISR_NonNakedBehaviour( void ) { if (gpio_get_pin_interrupt_flag(GPIO_PUSH_BUTTON_0)) { // set the flag bSendMail = pdTRUE; // allow new interrupt : clear the IFR flag gpio_clear_pin_interrupt_flag(GPIO_PUSH_BUTTON_0); } // no context switch required, task is polling the flag return( pdFALSE ); } #endif
the_stack_data/37202.c
/* PR rtl-optimization/79032 */ /* Reported by Daniel Cederman <[email protected]> */ extern void abort (void); struct S { short a; long long b; short c; char d; unsigned short e; long *f; }; static long foo (struct S *s) __attribute__((noclone, noinline)); static long foo (struct S *s) { long a = 1; a /= s->e; s->f[a]--; return a; } int main (void) { long val = 1; struct S s = { 0, 0, 0, 0, 2, &val }; val = foo (&s); if (val != 0) abort (); return 0; }