From: j. <jin...@qq...> - 2016-12-11 16:23:29
|
Hi experts: I'm reading the st source codes, and meet a question. In my understanding, the st should save the user-thread context pointers and the datas on the stack. That is, the MD_INIT_CONTEXT should be like this: 1: #define MD_INIT_CONTEXT(_thread, _sp, _bsp, _main) \ 2: ST_BEGIN_MACRO \ 3: if (MD_SETJMP((_thread)->context)) \ 4: _main(); \ 5: memcpy((char *)(_bsp) - MD_STACK_PAD_SIZE, \ (char *)(_thread)->context[0].__jmpbuf[17] - MD_STACK_PAD_SIZE, \ MD_STACK_PAD_SIZE); \ 6: (_thread)->context[0].__jmpbuf[0] = (long) (_sp); \ 7: (_thread)->context[0].__jmpbuf[17] = (long) (_bsp); \ ST_END_MACRO memcpy does the copying of the stack frame data from stack to per st_thread.stack , while line 6-7 copies the context pointers. But I only see this definition of MD_INIT_CONTEXT under IA_64 architecture, while the common MD_INIT_CONTEXT does't have memcpy. It's like this: #define MD_INIT_CONTEXT(_thread, _sp, _main) \ ST_BEGIN_MACRO \ if (MD_SETJMP((_thread)->context)) \ _main(); \ MD_GET_SP(_thread) = (long) (_sp); \ ST_END_MACRO Do I have any misunderstanding about this question? st should save context pointers and the frame data on the stack, is it right? Do I miss something important somewhere? |