Missing files
This commit is contained in:
parent
90128eb8e5
commit
3247e18798
8 changed files with 204 additions and 0 deletions
3
include/cpu/atomic.hpp
Normal file
3
include/cpu/atomic.hpp
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
int cmp_swap(int* old_int,int new_int){
|
||||||
|
|
||||||
|
}
|
21
include/misc/memory/util.h
Normal file
21
include/misc/memory/util.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define COLOR(color) "\e["color"m"
|
||||||
|
|
||||||
|
#define COL_BLACK COLOR("0;30")
|
||||||
|
#define COL_BLUE COLOR("0;34")
|
||||||
|
#define COL_GREEN COLOR("0;32")
|
||||||
|
#define COL_RED COLOR("0;31")
|
||||||
|
#define COL_NONE COLOR("0;0")
|
||||||
|
|
||||||
|
void p_mem(const char *label, void *pointer)
|
||||||
|
{
|
||||||
|
printf("%s:\t%p\t%ld\n", label, pointer, (long)pointer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void p_diff(const char *label,void *p1, void *p2){
|
||||||
|
printf("%s:\tp1:%p\tp2:%p\tdiff:\t%ld\n",label,p1,p2,(long)(p2-p1));
|
||||||
|
}
|
||||||
|
|
64
src/gui/gui1.cpp
Normal file
64
src/gui/gui1.cpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include <wx/wx.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class MyApp : public wxApp
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool OnInit();
|
||||||
|
};
|
||||||
|
class MyFrame : public wxFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MyFrame();
|
||||||
|
private:
|
||||||
|
void OnHello(wxCommandEvent& event);
|
||||||
|
void OnExit(wxCommandEvent& event);
|
||||||
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
};
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ID_Hello = 1
|
||||||
|
};
|
||||||
|
wxIMPLEMENT_APP(MyApp);
|
||||||
|
bool MyApp::OnInit()
|
||||||
|
{
|
||||||
|
MyFrame *frame = new MyFrame();
|
||||||
|
frame->Show(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
MyFrame::MyFrame()
|
||||||
|
: wxFrame(NULL, wxID_ANY, "Hello World")
|
||||||
|
{
|
||||||
|
wxMenu *menuFile = new wxMenu;
|
||||||
|
menuFile->Append(ID_Hello, "&Hello...\tCtrl-H",
|
||||||
|
"Help string shown in status bar for this menu item");
|
||||||
|
menuFile->AppendSeparator();
|
||||||
|
menuFile->Append(wxID_EXIT);
|
||||||
|
wxMenu *menuHelp = new wxMenu;
|
||||||
|
menuHelp->Append(wxID_ABOUT);
|
||||||
|
wxMenuBar *menuBar = new wxMenuBar;
|
||||||
|
menuBar->Append(menuFile, "&File");
|
||||||
|
menuBar->Append(menuHelp, "&Help");
|
||||||
|
SetMenuBar( menuBar );
|
||||||
|
CreateStatusBar();
|
||||||
|
SetStatusText("Welcome to wxWidgets!");
|
||||||
|
Bind(wxEVT_MENU, &MyFrame::OnHello, this, ID_Hello);
|
||||||
|
Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
|
||||||
|
Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
|
||||||
|
}
|
||||||
|
void MyFrame::OnExit(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
Close(true);
|
||||||
|
}
|
||||||
|
void MyFrame::OnAbout(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxMessageBox("This is a wxWidgets Hello World example",
|
||||||
|
"About Hello World", wxOK | wxICON_INFORMATION);
|
||||||
|
}
|
||||||
|
void MyFrame::OnHello(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxLogMessage("Hello world from wxWidgets!");
|
||||||
|
}
|
2
src/misc/dec/CMakeLists.txt
Normal file
2
src/misc/dec/CMakeLists.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
add_executable(dec_ex1 ex1.cpp)
|
||||||
|
add_executable(dec_ex2 ex2.cpp)
|
28
src/misc/dec/ex1.cpp
Normal file
28
src/misc/dec/ex1.cpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
static const char* license="x31lfkssfaskfs";
|
||||||
|
|
||||||
|
void showMessageError(){
|
||||||
|
std::cout << "Exiting program " << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void continueProgram(){
|
||||||
|
std::cout << "Continuing program " << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkLicence(){
|
||||||
|
std::string input;
|
||||||
|
std::cout << "Enter licence key" << std::endl;
|
||||||
|
std::cin >> input;
|
||||||
|
std::string licenceString = license;
|
||||||
|
if(licenceString==input){
|
||||||
|
continueProgram();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
showMessageError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
checkLicence();
|
||||||
|
}
|
7
src/misc/dec/ex2.cpp
Normal file
7
src/misc/dec/ex2.cpp
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(void){
|
||||||
|
std::string hello = "Hello world";
|
||||||
|
std::cout << hello;
|
||||||
|
return 5;
|
||||||
|
}
|
26
src/misc/memory/cautofree.c
Normal file
26
src/misc/memory/cautofree.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "../../../include/misc/memory/util.h"
|
||||||
|
|
||||||
|
#define AUTO_FREE __attribute__((cleanup(scoped_free)))
|
||||||
|
|
||||||
|
typedef struct Point
|
||||||
|
{
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
} Point;
|
||||||
|
|
||||||
|
void scoped_free(void *pointer)
|
||||||
|
{
|
||||||
|
printf("Scoped free invoked %p\n",pointer);
|
||||||
|
void **pp = (void**)pointer;
|
||||||
|
free(*pp);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
AUTO_FREE Point *p1 = (Point *)malloc(sizeof(Point));
|
||||||
|
p_mem("P1",p1);
|
||||||
|
AUTO_FREE Point *p2 = (Point *)malloc(sizeof(Point));
|
||||||
|
p_mem("P2",p2);
|
||||||
|
}
|
53
src/misc/memory/cmem.c
Normal file
53
src/misc/memory/cmem.c
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "../../../include/misc/memory/util.h"
|
||||||
|
|
||||||
|
void stack_frame2(void)
|
||||||
|
{
|
||||||
|
int b = 2;
|
||||||
|
|
||||||
|
p_mem("b", &b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void stack_frame1(void)
|
||||||
|
{
|
||||||
|
int a = 1;
|
||||||
|
p_mem("a", &a);
|
||||||
|
stack_frame2();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
int a = 12; p_mem("a", &a);
|
||||||
|
int b = 24; p_mem("b", &b);
|
||||||
|
int c = 48; p_mem("c", &c);
|
||||||
|
|
||||||
|
p_diff("b-a",&a,&b);
|
||||||
|
p_diff("c-b",&b,&c);
|
||||||
|
p_diff("c-a",&a,&c);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int x = 21; p_mem("x", &x);
|
||||||
|
int y = 42; p_mem("y", &y);
|
||||||
|
int z = 84; p_mem("z", &z);
|
||||||
|
|
||||||
|
p_diff("y-x",&x,&y);
|
||||||
|
p_diff("z-y",&y,&z);
|
||||||
|
p_diff("z-x",&x,&z);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
stack_frame1();
|
||||||
|
|
||||||
|
//int *p_int=(int*)malloc(sizeof(int));
|
||||||
|
//*p_int=12;
|
||||||
|
|
||||||
|
//printf("%d\n",*p_int);
|
||||||
|
//p_mem("p_int",p_int);
|
||||||
|
|
||||||
|
//free(p_int);
|
||||||
|
return getchar();
|
||||||
|
}
|
Loading…
Reference in a new issue