Skip to content

Instantly share code, notes, and snippets.

View Amanieu's full-sized avatar

Amanieu d'Antras Amanieu

View GitHub Profile
#include <functional>
#include <iostream>
// Detect whether the function takes an int argument or zero arguments
template<typename T, typename = decltype(std::declval<T>()(0))> std::true_type detect_type(const T&);
template<typename T, typename = decltype(std::declval<T>()())> std::false_type detect_type(const T&);
int main()
{
auto a = std::bind([](int){}, std::placeholders::_1); // Prints 1
#include "native_client/src/shared/imc/nacl_imc_c.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#define SEL_LDR "tools/sel_ldr_x86_64"
#define IRT "tools/irt_core_x86_64.nexe"
#define APP "a.nexe"
#define NACL_HANDLE_TRANSFER_PROTOCOL 0xd3c0de01
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <signal.h>
#endif
#include <stdio.h>
#include <string.h>
class VM {
public:
protected:
virtual void Syscall(int32_t index, Reader& input, Writer& output) = 0;
void DoRPC(const Writer& input, Reader& output);
private:
NaCl::Module* module;
};
template<typename T> class BasicStringRef {
BasicStringRef(const std::basic_string<T>& other)
{
ptr = other.c_str();
len = other.size();
}
BasicStringRef(const T* other)
{
ptr = other;
len = std::char_traits<T>::length(other);
/*
===========================================================================
Daemon GPL Source Code
Copyright (C) 2013 Unvanquished Developers
This file is part of the Daemon GPL Source Code (Daemon Source Code).
Daemon Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@Amanieu
Amanieu / chase_lev.cpp
Last active January 20, 2023 11:57
Chase-Lev deque implementation
// Copyright (c) 2013 Amanieu d'Antras
//
// 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
#!/usr/bin/python3
import sys
import os.path
import struct
IDENT = "IDP3"
VERSION = 15
f = ""
def printUsage():
diff --git a/src/common/IPC.h b/src/common/IPC.h
index cab883f..d1fcaee 100644
--- a/src/common/IPC.h
+++ b/src/common/IPC.h
@@ -209,7 +209,7 @@ template<> struct SerializeTraits<std::string> {
};
// IPC message, which automatically serializes and deserializes objects
-template<typename... T> class Message {
+template<uint32_t Major, uint32_t Minor, typename... T> class Message {
diff --git a/src/common/IPC.h b/src/common/IPC.h
index c3dbc5c..38778a1 100644
--- a/src/common/IPC.h
+++ b/src/common/IPC.h
@@ -46,9 +46,86 @@ Maryland 20850 USA.
#include "../engine/qcommon/q_shared.h"
#include "../engine/qcommon/qcommon.h"
+namespace IPC {
+