void readWindowTest( uint64_t doff, const char* enc, size_t hbeg, size_t hend, size_t pre, size_t post, const std::vector<byte>& data, const std::vector<int32_t>& ecp, const std::vector<size_t>& eoff) { const LG_Window inner{doff + hbeg, doff + hend}; int32_t* chars = nullptr; size_t* offsets = nullptr; size_t clen; LG_Error* err = nullptr; const unsigned int abad = lg_read_window( reinterpret_cast<const char*>(data.data()), reinterpret_cast<const char*>(data.data()) + data.size(), doff, &inner, enc, pre, post, &chars, &offsets, &clen, &err ); if (err) { const std::string msg(err->Message); lg_free_error(err); throw std::runtime_error(msg); } std::unique_ptr<int32_t[],void(*)(int32_t*)> pchars( chars, &lg_free_window_characters ); std::unique_ptr<size_t[],void(*)(size_t*)> poff( offsets, &lg_free_window_offsets ); const size_t ebad = std::count_if( ecp.begin(), ecp.end()-1, [](int32_t v){ return v < 0; } ); SCOPE_ASSERT_EQUAL(ebad, abad); std::vector<int32_t> acp(chars, chars+clen); SCOPE_ASSERT_EQUAL(ecp, acp); std::vector<size_t> aoff(offsets, offsets+clen); SCOPE_ASSERT_EQUAL(eoff, aoff); }
/* * Convert a kernel virtual address to a Physical Address/Length List. */ alenlist_t kvaddr_to_alenlist(alenlist_t alenlist, caddr_t kvaddr, size_t length, unsigned flags) { alenaddr_t paddr; long offset; size_t piece_length; int created_alenlist; if (length <=0) return(NULL); /* If caller supplied a List, use it. Otherwise, allocate one. */ if (alenlist == NULL) { alenlist = alenlist_create(0); created_alenlist = 1; } else { alenlist_clear(alenlist); created_alenlist = 0; } paddr = kvtophys(kvaddr); offset = poff(kvaddr); /* Handle first page */ piece_length = min((size_t)(NBPP - offset), length); if (alenlist_append(alenlist, paddr, piece_length, flags) == ALENLIST_FAILURE) goto failure; length -= piece_length; kvaddr += piece_length; /* Handle middle pages */ while (length >= NBPP) { paddr = kvtophys(kvaddr); if (alenlist_append(alenlist, paddr, NBPP, flags) == ALENLIST_FAILURE) goto failure; length -= NBPP; kvaddr += NBPP; } /* Handle last page */ if (length) { ASSERT(length < NBPP); paddr = kvtophys(kvaddr); if (alenlist_append(alenlist, paddr, length, flags) == ALENLIST_FAILURE) goto failure; } alenlist_cursor_init(alenlist, 0, NULL); return(alenlist); failure: if (created_alenlist) alenlist_destroy(alenlist); return(NULL); }
*/ #include <X11/IntrinsicP.h> #include <X11/StringDefs.h> /* get XtN and XtC defines */ #include "XawInit.h" /* get Xaw initialize stuff */ #include "PortholeP.h" /* get porthole structs */ #include <X11/Xmu/Misc.h> /* for MAX */ /* * resources for the porthole */ static XtResource resources[] = { #define poff(field) XtOffsetOf(PortholeRec, porthole.field) { XtNreportCallback, XtCReportCallback, XtRCallback, sizeof(XtPointer), poff(report_callbacks), XtRCallback, (XtPointer) NULL }, #undef poff }; /* * widget class methods used below */ static void Realize(); /* set gravity and upcall */ static void Resize(); /* report new size */ static XtGeometryResult GeometryManager(); /* deal with child requests */ static void ChangeManaged(); /* somebody added a new widget */ static XtGeometryResult QueryGeometry(); /* say how big would like to be */ PortholeClassRec portholeClassRec = { { /* core fields */
#define CW_CHILD_NAT_WIDTH CW_CLIP.child_width_nat #define CW_CHILD_NAT_HEIGHT CW_CLIP.child_height_nat #define CW_CHILD_NAT_X CW_CLIP.child_x_nat #define CW_CHILD_NAT_Y CW_CLIP.child_y_nat #define CW_CHILD_NAT_BORDER CW_CLIP.child_border_nat #define CW_CHILD_P CW_COMPOSITE.children #define CW_CHILD (CW_COMPOSITE.children[0]) /* * resources for the clip */ static XtResource resources[] = { #define poff(field) XtOffsetOf(ClipRec, clip.field) { XtNreportCallback, XtCReportCallback, XtRCallback, sizeof(XtPointer), poff(report_callbacks), XtRCallback, (XtPointer) NULL }, #if 0 { XtNchildX, XtCChildX, XtRInt, sizeof(int), poff(child_x), XtRImmediate, (XtPointer) 0 }, { XtNchildY, XtCChildY, XtRInt, sizeof(int), poff(child_y), XtRImmediate, (XtPointer) 0 }, #endif #undef poff }; /* * widget class methods used below */ static void InsertChild(Widget); static void Initialize(Widget,Widget,ArgList,Cardinal*);