Integer EnsureVirtualAddressRange (Integer vma, int count) { int pages = ceiling(count, MemoryPageSize); caddr_t data, tag; Integer aligned_vma = vma - MemoryPageOffset(vma); int n; while (pages) { n = 0; while (!Created (vma) && pages) { n++; pages--; SetCreated(vma); vma += MemoryPageSize; } if (n) { data = (caddr_t)&DataSpace[aligned_vma]; tag = (caddr_t)&TagSpace[aligned_vma]; if (data != mmap(data, n * sizeof(Integer[MemoryPageSize]), PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_FIXED,-1,0)) punt ("Couldn't map %d data pages at %x for VMA %x", n, data, aligned_vma); if (tag != mmap(tag, n * sizeof(Tag[MemoryPageSize]), PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_FIXED,-1,0)) punt ("Couldn't map %d tag pages at %x for VMA %x", n, tag, aligned_vma); aligned_vma += n * MemoryPageSize; } while (Created (vma) && pages) { pages--; vma += MemoryPageSize; aligned_vma += MemoryPageSize; } } return(vma); }
int main() { SList s,s1,s2; s1=Created(); s2=Created(); PrintData(s1); PrintData(s2); s=Merge(s1,s2); printf("\t"); PrintData(s); }
// // PEP-modules call this when the used pipe blocks // void CNifContext::BlockIndication() { TContextInfo info; // TRequestStatus status; // for local use //TContextReasonCode operationCode = KContextOk; TInt operationCode = KErrNone; info.iStatus = Status(); info.iContextId = ContextId(); // Build response event // TContextParameters BlockEvent; TContextParameters* BlockEvent = NULL; TRAPD(err, BlockEvent = new (ELeave) TContextParameters()); if (err) return; BlockEvent->iReasonCode = operationCode; BlockEvent->iContextInfo = info; BlockEvent->iContextType = ContextType(); TPckg<TContextParameters> event(*BlockEvent); // Event built // Send Blocked event to GUQoS if(Nif().EventsOn() && Created() && Usable()) { LOG(Log::Printf(_L("<%s> Sending blocked event for [Context %d]"),Nif().Name().PtrZ(),BlockEvent->iContextInfo.iContextId)); Nif().EventHandler().Event((CProtocolBase*)&Nif(),KContextBlockedEvent,event); // Notify the upper layer } // The stack will receive the block info via Send() -method's return value // when sending packets. delete BlockEvent; BlockEvent=NULL; }
int main() { AdjMatrix *a; a=(AdjMatrix *)malloc(sizeof(AdjMatrix)); Created(a); printf("\n\n"); PrintMatrix(a); }
int main() { AdjList *a; a=(AdjList *)malloc(sizeof(AdjList)); Created(a); Print(a); printf("\n\n"); BFS_All(a); }
int main() { BST *b=NULL,*p=NULL,*q; Created(&b); printf("\n"); Print(b); printf("\n"); q=DeleteBST(b,72); Print(q); printf("\n"); }
// // Unblock and block-indications for packetinterface // void CNifContext::UnblockIndication() { TContextInfo info; // TRequestStatus status; // for local use //TContextReasonCode operationCode = KContextOk; TInt operationCode = KErrNone; info.iStatus = Status(); info.iContextId = ContextId(); // Build response event // TContextParameters UnblockEvent; TContextParameters* UnblockEvent = NULL; TRAPD(err, UnblockEvent = new (ELeave) TContextParameters()); if (err) return; UnblockEvent->iReasonCode = operationCode; UnblockEvent->iContextInfo = info; UnblockEvent->iContextType = ContextType(); TPckg<TContextParameters> event(*UnblockEvent); // Event built // Send unblocked event to GUQoS if(Nif().EventsOn() && Created() && Usable()) { LOG(Log::Printf(_L("<%s> Sending unblocked event for [Context %d]"),Nif().Name().PtrZ(),UnblockEvent->iContextInfo.iContextId)); Nif().EventHandler().Event((CProtocolBase*)&Nif(),KContextUnblockedEvent,event); // Notify the upper layer } // Without signalling module or events of, call StartSending() else if (Created() && Usable()) { Nif().Network()->StartSending((CProtocolBase*)&Nif()); } delete UnblockEvent; UnblockEvent=NULL; }
// // Indicate QoS has changed // void CNifContext::ContextInternalEvent(RPacketQoS::TQoSR5Negotiated aContextQoS) { // Next we should check if the context is still up and running if(Nif().EventsOn() && Created() && Usable()) // Change the created to indicate active in GuQoS { if(!PendingModification()) { // If we had a pending QoS it is now invalid anyway.. ResetPendingQoS(); RPacketQoS::TQoSR5Negotiated currentQoS; Parameters().iContextConfig.GetUMTSQoSNeg(currentQoS); if(!IdenticalQoS(aContextQoS,currentQoS)) { Parameters().iContextConfig.SetUMTSQoSNeg(aContextQoS); // TContextParameters contextQoSChangeEvent; TContextParameters* contextQoSChangeEvent = NULL; TRAPD(err, contextQoSChangeEvent = new (ELeave) TContextParameters()); if (err) return; FillEvent(*contextQoSChangeEvent); // Standard info FillEventQoS(*contextQoSChangeEvent); // QoS FillEventTFT(*contextQoSChangeEvent); // TFT TPckg<TContextParameters> event(*contextQoSChangeEvent); // A boolean variable to mark if the setqos request is from user (or network?) // if this is from the user do not generate any event but if it is by the network // then generate the event if ( iManualQosRequest ) { LOG(Log::Printf(_L("<%s> Sending KContextParametersChangeEvent event for [Context %d]"),Nif().Name().PtrZ(),contextQoSChangeEvent->iContextInfo.iContextId)); Nif().EventHandler().Event((CProtocolBase*)&(Nif()),KContextParametersChangeEvent,event); iManualQosRequest = EFalse; } delete contextQoSChangeEvent; contextQoSChangeEvent=NULL; } } else { SetPendingQoS(aContextQoS); } } return; }
Integer DestroyVirtualAddress (Integer vma) { caddr_t data, tag; Integer aligned_vma = vma - MemoryPageOffset(vma); if (!Created(vma)) return(vma); data = (caddr_t)&DataSpace[aligned_vma]; tag = (caddr_t)&TagSpace[aligned_vma]; if (munmap(data, sizeof(Integer[MemoryPageSize]))) punt ("Couldn't unmap data page at %x for VMA %x", data, vma); if (munmap(tag, sizeof(Tag[MemoryPageSize]))) punt ("Couldn't unmap tag page at %x for VMA %x", tag, vma); ClearCreated(vma); return(vma); }
int main(int argc, char *argv[]) { int i = 0; stu *q; puts("输入插入节点的个数"); scanf("%d", &i); q = Created(i); q = output(q); printf("输出结果:\n"); while(q) { printf("%s\t", q->name); q = q->prior; } return 0; }
Integer EnsureVirtualAddress (Integer vma) { caddr_t data, tag; Integer aligned_vma = vma - MemoryPageOffset(vma); if (Created(vma)) return(vma); data = (caddr_t)&DataSpace[aligned_vma]; tag = (caddr_t)&TagSpace[aligned_vma]; if (data != mmap(data, sizeof(Integer[MemoryPageSize]), PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_FIXED,-1,0)) punt ("Couldn't map data page at %x for VMA %x", data, vma); if (tag != mmap(tag, sizeof(Tag[MemoryPageSize]), PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_FIXED,-1,0)) punt ("Couldn't map tag page at %x for VMA %x", tag, vma); SetCreated(vma); return(vma); }
bool SharedMemoryBasic::Create(size_t aNbytes) { NS_ABORT_IF_FALSE(-1 == mShmFd, "Already Create()d"); // Carve a new instance off of /dev/ashmem int shmfd = open("/" ASHMEM_NAME_DEF, O_RDWR, 0600); if (-1 == shmfd) { LogError("ShmemAndroid::Create():open"); return false; } if (ioctl(shmfd, ASHMEM_SET_SIZE, aNbytes)) { LogError("ShmemAndroid::Unmap():ioctl(SET_SIZE)"); close(shmfd); return false; } mShmFd = shmfd; Created(aNbytes); return true; }
void Nena::Application::Window::Initialize( _In_ Nena::Application::Window::Callback proc, _In_opt_ Nena::Application::Window::Boolean cursor ) { if (Raw) return; ::OutputDebugStringA("Nena::Application::Window::Initialize()\n"); Window::WindowClass wc; Window::ScreenSettings screen; ::INT status = 0; ::HMONITOR monitorHandle; ::MONITORINFOEXA monitorInfo; status = FALSE; monitorHandle = NULL; ZeroMemory(&screen, sizeof Window::ScreenSettings); ZeroMemory(&wc, sizeof Window::WindowClass); // Setup windows class with default settings. wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.hbrBackground = (::HBRUSH)GetStockObject(BLACK_BRUSH); wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.cbSize = sizeof(WindowClass); wc.lpszClassName = Name.c_str(); wc.lpszMenuName = NULL; wc.lpfnWndProc = proc; wc.hIconSm = wc.hIcon; wc.hInstance = Instance; wc.cbClsExtra = 0; wc.cbWndExtra = 0; // Register window class. auto atom = ::RegisterClassExA(&wc); if (atom == INVALID_ATOM) { auto error = GetLastError(); return; } else status = TRUE; status = TRUE; POINT point = { 0 }; // in the virtual screen space, primary display rect starts from (0, 0), // so it should return a handle to a default device monitorHandle = ::MonitorFromPoint(point, MONITOR_DEFAULTTOPRIMARY); if (monitorHandle == INVALID_HANDLE_VALUE || monitorHandle == NULL) OutputDebugStringA("\tFailed to get current monitor handle\n"), status = FALSE; ZeroMemory(&monitorInfo, sizeof MONITORINFOEXA); monitorInfo.cbSize = sizeof MONITORINFOEXA; if (status && !::GetMonitorInfoA(monitorHandle, &monitorInfo)) OutputDebugStringA("\tFailed to get current monitor info\n"), status = FALSE; if (!status) { // an attempt to find monitor manually // or return the last one if ok status = EnumDisplayMonitors(NULL, NULL, (MONITORENUMPROC)[]( HMONITOR monitor, HDC context, LPRECT rect, LPARAM data ) { _CRT_UNUSED(context); ((HMONITOR &) data) = monitor; if (rect->left == 0 && rect->top == 0) return FALSE; else return TRUE; }, (LPARAM) (HMONITOR &) monitorHandle ); if (status) status = monitorHandle != INVALID_HANDLE_VALUE && monitorHandle != NULL; } if (status) { // current monitor was found ScreenWidth = (decltype(ScreenWidth)) (monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left); ScreenHeight = (decltype(ScreenHeight)) (monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top); X = (Int16) (monitorInfo.rcMonitor.left + (ScreenWidth - Width) / 2); Y = (Int16) (monitorInfo.rcMonitor.top + (ScreenHeight - Height) / 2); } else // all the attempts to find monitor device failed, try another approach { ::ZeroMemory(&screen, sizeof ScreenSettings); if (!::EnumDisplaySettingsA(nullptr, ENUM_CURRENT_SETTINGS, &screen)) OutputDebugStringA("\tFailed to get current display device\n"), status = FALSE, ScreenWidth = 0, ScreenHeight = 0; else ScreenWidth = (UInt16)screen.dmPelsWidth, ScreenHeight = (UInt16)screen.dmPelsHeight, X = (Int16)((ScreenWidth - Width) / 2), Y = (Int16)((ScreenHeight - Height) / 2); } if (Fullscreen) Raw = ::CreateWindowExA( WS_EX_APPWINDOW, Name.c_str(), Name.c_str(), Style, X, Y, ScreenWidth, ScreenHeight, nullptr, nullptr, Instance, nullptr ); else Raw = ::CreateWindowExA( WS_EX_APPWINDOW, Name.c_str(), Name.c_str(), Style, X, Y, Width, Height, nullptr, nullptr, Instance, nullptr ); if (Raw) // if window was created { ::ShowWindow(Raw, SW_SHOW); ::SetForegroundWindow(Raw); ::SetFocus(Raw); ::ShowCursor(cursor); // adjust window Fullscreen = !Fullscreen; ToggleFullscreen(); } // notify a developer about window was created // (or was not, should check a handle) Created(this); }