text
stringlengths 9
5.83M
|
|---|
/*
* Copyright (C) 2017 spreadtrum.com
*/
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <err.h>
#include <trusty_std.h>
#include <stdio.h>
#include <lib/sprdimgversion/sprdimgversion.h>
#define LOG_TAG "libsprdimgversion"
#define TLOGE(fmt, ...) \
fprintf(stderr, "%s: %d: " fmt, LOG_TAG, __LINE__, ## __VA_ARGS__)
static int sprdimgversion_check_res(struct sprdimgversion_msg *msg, int res)
{
if ((size_t)res < sizeof(*msg)) {
TLOGE("invalid msg length (%zd < %zd)\n", res, sizeof(*msg));
return ERR_NOT_VALID;
}
switch(msg->result) {
case SPRDIMGVERSION_NO_ERROR:
return res - sizeof(*msg);
case SPRDIMGVERSION_ERR_NOT_VALID:
TLOGE("cmd 0x%x: parameter is invalid\n", msg->cmd);
return ERR_NOT_VALID;
case SPRDIMGVERSION_ERR_UNIMPLEMENTED:
TLOGE("cmd 0x%x: is unhandles command\n", msg->cmd);
return ERR_NOT_VALID;
case SPRDIMGVERSION_ERR_GENERIC:
TLOGE("cmd 0x%x: internal server error\n", msg->cmd);
return ERR_GENERIC;
default:
TLOGE("cmd 0x%x: unhandled server response %u\n", msg->cmd, msg->result);
}
return ERR_GENERIC;
}
static ssize_t sprdimgversion_get_res(sprdimgversion_session_t session,
struct iovec *rx_iovs, uint rx_iovcnt)
{
uevent_t ev;
struct ipc_msg_info mi;
struct ipc_msg rx_msg = {
.iov = rx_iovs,
.num_iov = rx_iovcnt,
};
if (!rx_iovcnt)
return 0;
/* wait for reply */
int rc = wait(session, &ev, -1);
if (rc != NO_ERROR) {
TLOGE("%s: interrupted waiting for response", __func__);
return rc;
}
rc = get_msg(session, &mi);
if (rc != NO_ERROR) {
TLOGE("%s: failed to get_msg (%d)\n", __func__, rc);
return rc;
}
rc = read_msg(session, mi.id, 0, &rx_msg);
put_msg(session, mi.id);
if (rc < 0) {
TLOGE("%s: failed to read msg (%d)\n", __func__, rc);
return rc;
}
if ((size_t)rc != mi.len) {
TLOGE("%s: partial message read (%zd vs. %zd)\n",
__func__, (size_t)rc, mi.len);
return ERR_IO;
}
return rc;
}
static int sprdimgversion_wait_to_send(handle_t session, struct ipc_msg *msg)
{
struct uevent ev;
int rc;
rc = wait(session, &ev, -1);
if (rc < 0) {
TLOGE("failed to wait for outgoing queue to free up\n");
return rc;
}
if (ev.event & IPC_HANDLE_POLL_SEND_UNBLOCKED) {
return send_msg(session, msg);
}
if (ev.event & IPC_HANDLE_POLL_MSG) {
return ERR_BUSY;
}
if (ev.event & IPC_HANDLE_POLL_HUP) {
return ERR_CHANNEL_CLOSED;
}
return rc;
}
static ssize_t sprdimgversion_send_req(sprdimgversion_session_t session,
struct iovec *tx_iovs, uint tx_iovcnt,
struct iovec *rx_iovs, uint rx_iovcnt)
{
ssize_t rc;
struct ipc_msg tx_msg = {
.iov = tx_iovs,
.num_iov = tx_iovcnt,
};
rc = send_msg(session, &tx_msg);
if (rc == ERR_NOT_ENOUGH_BUFFER) {
rc = sprdimgversion_wait_to_send(session, &tx_msg);
}
if (rc < 0) {
TLOGE("%s: failed (%d) to send_msg\n", __func__, (int)rc);
return rc;
}
rc = sprdimgversion_get_res(session, rx_iovs, rx_iovcnt);
if (rc < 0) {
TLOGE("%s: failed (%d) to get response\n", __func__, (int)rc);
return rc;
}
return rc;
}
/*
*@session session handle retrieved from sprdimgversion_open
*@imgType The image which need to write the version
*@swVersion return image version
*Return value: zero is ok
*/
int sprd_set_imgversion(sprdimgversion_session_t session, antirb_image_type imgType, unsigned int swVersion)
{
struct sprdimgversion_msg msg = { .cmd = SPRDIMGVERSION_SET};
struct sprdimgversion_get_set_msg req = { .img_type = imgType, .img_version = swVersion };
struct iovec tx[2] = {{&msg, sizeof(msg)}, {&req, sizeof(req)}};
struct iovec rx[1] = {{&msg, sizeof(msg)}};
ssize_t rc = sprdimgversion_send_req(session, tx, 2, rx, 1);
return sprdimgversion_check_res(&msg, rc);
}
/*
*@session session handle retrieved from sprdimgversion_open
*@imgType The image which need to get the version
*@swVersion return image version
*Return value: zero is ok
*
*/
int sprd_get_imgversion(sprdimgversion_session_t session, antirb_image_type imgType, unsigned int* swVersion)
{
struct sprdimgversion_msg msg = { .cmd = SPRDIMGVERSION_GET};
struct sprdimgversion_get_set_msg req = { .img_type = imgType, .img_version = 0 };
struct iovec tx[2] = {{&msg, sizeof(msg)}, {&req, sizeof(req)}};
struct iovec rx[2] = {{&msg, sizeof(msg)}, {&req, sizeof(req)}};
if (swVersion == NULL) {
return ERR_NOT_VALID;
}
ssize_t rc = sprdimgversion_send_req(session, tx, 2, rx, 2);
rc = sprdimgversion_check_res(&msg, rc);
if (rc < 0) { return rc;}
if (rc < (ssize_t)sizeof(req)) {
TLOGE("%s: response lenth error,%d,exp %d\n", __func__, (int)rc, sizeof(req));
return ERR_NOT_VALID;
}
*swVersion = req.img_version;
return 0;
}
/**
* sprdimgversion_open() - Opens a trusty sprdimgversion session.
*
* Return: 0 on success, * or an error code < 0 on
* failure.
*/
int sprdimgversion_open(sprdimgversion_session_t *session)
{
long ret;
ret = connect(SPRDIMGVERSION_CLIENT_PORT, 0);
if (ret < 0) {
return ret;
} else {
*session = ret;
return 0;
}
}
/**
* sprdimgversion_close() - Closes the session.
*/
void sprdimgversion_close(sprdimgversion_session_t session)
{
close(session);
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "commo_header.h"
#include "parse_utili.h"
//
// -1:error 0x00:normal 0x01:constructor
int check_space_type(char *clasn, char *metnm, char *decla, char *space) {
char *toksp = kill_blank(space);
if (!toksp) return -1;
char *tokep = strchr(toksp, ':');
if (!tokep) return -1;
strzcpy(clasn, toksp, tokep - toksp);
//
toksp = strpbrk(++tokep, " (");
if (!toksp) return -1;
strzcpy(metnm, tokep, toksp - tokep);
//
if ('(' != toksp[0x00]) toksp = strchr(toksp + 0x01, '(');
if (!toksp) return -1;
tokep = strchr(tokep, ')');
if (!tokep) return -1;
strzcpy(decla, toksp, tokep - toksp + 0x01);
//
if (strcmp(clasn, metnm)) return 0x00;
return 0x01;
}
char *split_space(char *clasn, char *metnm, char *space) {
char *toksp = kill_blank(space);
if (!toksp) return NULL;
char *tokep = strchr(toksp + 0x01, ':');
if (!tokep) return NULL;
strzcpy(clasn, toksp, tokep - toksp);
strcpy(metnm, tokep + 0x01);
//
return clasn;
}
//
char *split_space_ex(char *clasn, char *metnm, char *space) {
char *toksp = kill_blank(space);
if (!toksp) return NULL;
char *tokep = strchr(toksp + 0x01, ':');
if (!tokep) return NULL;
strzcpy(clasn, toksp, tokep - toksp);
//
toksp = strpbrk(tokep + 0x01, " <");
if (!toksp) return NULL;
strzcpy(metnm, tokep + 0x01, toksp - tokep - 0x01);
//
return toksp;
}
//
char *split_metho_ex(char *clasn, char *metnm, char *decla, char *space) {
char *toksp = kill_blank(space);
if (!toksp) return NULL;
char *tokep = strchr(toksp + 0x01, ':');
if (!tokep) return NULL;
strzcpy(clasn, toksp, tokep - toksp);
//
toksp = strpbrk(tokep + 0x01, " <");
if (!toksp) return NULL;
strzcpy(metnm, tokep + 0x01, toksp - tokep - 0x01);
//
if ('<' != toksp[0x00]) toksp = strchr(toksp + 0x01, '<');
if (!toksp) return NULL;
tokep = strchr(toksp + 0x01, '>');
if (!tokep) return NULL;
strzcpy(decla, toksp, tokep - toksp + 0x01);
//
return tokep + 0x01;
}
//
char *build_retyp_parse(char *retyn, char *parsn, char *handn) {
char *last_str = lccpy(retyn, '_');
last_str = lscpy(last_str, handn);
lscpy(last_str, "_retype_");
//
last_str = lscpy(parsn, "_parse_");
last_str = lscpy(last_str, handn);
lccpy(last_str, '_');
//
return parsn;
}
char *build_obsc_name(char *osize, char *bindn, char *solvn, char *clasn) {
char * last_str = lccpy(osize, '_');
last_str = lscpy(last_str, clasn);
lscpy(last_str, "_size_");
//
last_str = lscpy(bindn, "_bind_");
last_str = lscpy(last_str, clasn);
lccpy(last_str, '_');
//
last_str = lscpy(solvn, "_solve_");
last_str = lscpy(last_str, clasn);
lccpy(last_str, '_');
//
return osize;
}
char *split_metn(char *metnm, char *parsn, char *space) {
char *toke = strchr(space, ':');
if (!toke) return NULL;
strcpy(metnm, toke + 0x01);
char *last_str = lscpy(parsn, "p_");
lscpy(last_str, metnm);
//
return metnm;
}
//
char *split_clame(char *clame, char *space) {
char *toksp = kill_blank(space);
if (!toksp) return NULL;
char *tokep = strpbrk(toksp, " <");
if (!tokep) return NULL;
strzcpy(clame, toksp, tokep - toksp);
return clame;
}
|
#include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<errno.h>
#include<netinet/in.h>
#include<string.h>
#include<sys/wait.h>
#include<arpa/inet.h>
#include<stdlib.h>
#include<unistd.h>
void sendstring(int sd,char *string);
int main(int argc,char *argv[])
{
int sd,fd;
int con_ret;
struct sockaddr_in serveradd;
sd=socket(AF_INET,SOCK_STREAM,0);
if(sd<0)
{
perror("socket");
exit(1);
}
if(argv[1]==NULL)
{
printf("Please enter server's IP address\n");
exit(0);
}
if(argv[2]==NULL)
{
printf("Please enter server's port\n");
exit(0);
}
if(argv[3]==NULL)
{
printf("Please enter the string to be send to the server\n");
exit(0);
}
memset(&serveradd,0,sizeof(serveradd));
serveradd.sin_family=AF_INET;
serveradd.sin_port=htons(atoi(argv[2]));
serveradd.sin_addr.s_addr=inet_addr(argv[1]);
con_ret=connect(sd,(struct sockaddr*)&serveradd,sizeof(serveradd));
if(con_ret<0)
{
printf("Cannot connect to server\n");
exit(1);
}
sendstring(sd,argv[3]);
return 0;
}
void sendstring(int sd,char *string)
{
int n,byteswritten=0,written;
char buffer[1024];
strcpy(buffer,string);
n=strlen(buffer);
while(byteswritten<n)
{
written=write(sd,buffer+byteswritten,(n-byteswritten));
byteswritten+=written;
}
printf("String %s sent to server\n",buffer);
}
|
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019-2020 Damien P. George
*
* 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
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include "py/runtime.h"
#include "py/stream.h"
#include "py/mperrno.h"
#include "extmod/vfs.h"
STATIC void MP_VFS_LFSx(check_open)(MP_OBJ_VFS_LFSx_FILE * self) {
if (self->vfs == NULL) {
mp_raise_ValueError(NULL);
}
}
STATIC void MP_VFS_LFSx(file_print)(const mp_print_t * print, mp_obj_t self_in, mp_print_kind_t kind) {
(void)self_in;
(void)kind;
mp_printf(print, "<io.%s>", mp_obj_get_type_str(self_in));
}
mp_obj_t MP_VFS_LFSx(file_open)(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode_in) {
MP_OBJ_VFS_LFSx *self = MP_OBJ_TO_PTR(self_in);
int flags = 0;
const mp_obj_type_t *type = &MP_TYPE_VFS_LFSx_(_textio);
const char *mode_str = mp_obj_str_get_str(mode_in);
for (; *mode_str; ++mode_str) {
int new_flags = 0;
switch (*mode_str) {
case 'r':
new_flags = LFSx_MACRO(_O_RDONLY);
break;
case 'w':
new_flags = LFSx_MACRO(_O_WRONLY) | LFSx_MACRO(_O_CREAT) | LFSx_MACRO(_O_TRUNC);
break;
case 'x':
new_flags = LFSx_MACRO(_O_WRONLY) | LFSx_MACRO(_O_CREAT) | LFSx_MACRO(_O_EXCL);
break;
case 'a':
new_flags = LFSx_MACRO(_O_WRONLY) | LFSx_MACRO(_O_CREAT) | LFSx_MACRO(_O_APPEND);
break;
case '+':
flags |= LFSx_MACRO(_O_RDWR);
break;
#if MICROPY_PY_IO_FILEIO
case 'b':
type = &MP_TYPE_VFS_LFSx_(_fileio);
break;
#endif
case 't':
type = &MP_TYPE_VFS_LFSx_(_textio);
break;
}
if (new_flags) {
if (flags) {
mp_raise_ValueError(NULL);
}
flags = new_flags;
}
}
if (flags == 0) {
flags = LFSx_MACRO(_O_RDONLY);
}
#if LFS_BUILD_VERSION == 1
MP_OBJ_VFS_LFSx_FILE *o = m_new_obj_var_with_finaliser(MP_OBJ_VFS_LFSx_FILE, uint8_t, self->lfs.cfg->prog_size);
#else
MP_OBJ_VFS_LFSx_FILE *o = m_new_obj_var_with_finaliser(MP_OBJ_VFS_LFSx_FILE, uint8_t, self->lfs.cfg->cache_size);
#endif
o->base.type = type;
o->vfs = self;
#if !MICROPY_GC_CONSERVATIVE_CLEAR
memset(&o->file, 0, sizeof(o->file));
memset(&o->cfg, 0, sizeof(o->cfg));
#endif
o->cfg.buffer = &o->file_buffer[0];
#if LFS_BUILD_VERSION == 2
if (self->enable_mtime) {
lfs_get_mtime(&o->mtime[0]);
o->attrs[0].type = LFS_ATTR_MTIME;
o->attrs[0].buffer = &o->mtime[0];
o->attrs[0].size = sizeof(o->mtime);
o->cfg.attrs = &o->attrs[0];
o->cfg.attr_count = MP_ARRAY_SIZE(o->attrs);
}
#endif
const char *path = MP_VFS_LFSx(make_path)(self, path_in);
int ret = LFSx_API(file_opencfg)(&self->lfs, &o->file, path, flags, &o->cfg);
if (ret < 0) {
o->vfs = NULL;
mp_raise_OSError(-ret);
}
return MP_OBJ_FROM_PTR(o);
}
STATIC mp_obj_t MP_VFS_LFSx(file___exit__)(size_t n_args, const mp_obj_t *args) {
(void)n_args;
return mp_stream_close(args[0]);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(MP_VFS_LFSx(file___exit___obj), 4, 4, MP_VFS_LFSx(file___exit__));
STATIC mp_uint_t MP_VFS_LFSx(file_read)(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {
MP_OBJ_VFS_LFSx_FILE *self = MP_OBJ_TO_PTR(self_in);
MP_VFS_LFSx(check_open)(self);
LFSx_API(ssize_t) sz = LFSx_API(file_read)(&self->vfs->lfs, &self->file, buf, size);
if (sz < 0) {
*errcode = -sz;
return MP_STREAM_ERROR;
}
return sz;
}
STATIC mp_uint_t MP_VFS_LFSx(file_write)(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) {
MP_OBJ_VFS_LFSx_FILE *self = MP_OBJ_TO_PTR(self_in);
MP_VFS_LFSx(check_open)(self);
#if LFS_BUILD_VERSION == 2
if (self->vfs->enable_mtime) {
lfs_get_mtime(&self->mtime[0]);
}
#endif
LFSx_API(ssize_t) sz = LFSx_API(file_write)(&self->vfs->lfs, &self->file, buf, size);
if (sz < 0) {
*errcode = -sz;
return MP_STREAM_ERROR;
}
return sz;
}
STATIC mp_uint_t MP_VFS_LFSx(file_ioctl)(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
MP_OBJ_VFS_LFSx_FILE *self = MP_OBJ_TO_PTR(self_in);
if (request != MP_STREAM_CLOSE) {
MP_VFS_LFSx(check_open)(self);
}
if (request == MP_STREAM_SEEK) {
struct mp_stream_seek_t *s = (struct mp_stream_seek_t *)(uintptr_t)arg;
int res = LFSx_API(file_seek)(&self->vfs->lfs, &self->file, s->offset, s->whence);
if (res < 0) {
*errcode = -res;
return MP_STREAM_ERROR;
}
res = LFSx_API(file_tell)(&self->vfs->lfs, &self->file);
if (res < 0) {
*errcode = -res;
return MP_STREAM_ERROR;
}
s->offset = res;
return 0;
} else if (request == MP_STREAM_FLUSH) {
int res = LFSx_API(file_sync)(&self->vfs->lfs, &self->file);
if (res < 0) {
*errcode = -res;
return MP_STREAM_ERROR;
}
return 0;
} else if (request == MP_STREAM_CLOSE) {
if (self->vfs == NULL) {
return 0;
}
int res = LFSx_API(file_close)(&self->vfs->lfs, &self->file);
self->vfs = NULL; // indicate a closed file
if (res < 0) {
*errcode = -res;
return MP_STREAM_ERROR;
}
return 0;
} else {
*errcode = MP_EINVAL;
return MP_STREAM_ERROR;
}
}
STATIC const mp_rom_map_elem_t MP_VFS_LFSx(file_locals_dict_table)[] = {
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
{ MP_ROM_QSTR(MP_QSTR_readlines), MP_ROM_PTR(&mp_stream_unbuffered_readlines_obj) },
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_flush), MP_ROM_PTR(&mp_stream_flush_obj) },
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) },
{ MP_ROM_QSTR(MP_QSTR_seek), MP_ROM_PTR(&mp_stream_seek_obj) },
{ MP_ROM_QSTR(MP_QSTR_tell), MP_ROM_PTR(&mp_stream_tell_obj) },
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) },
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&MP_VFS_LFSx(file___exit___obj)) },
};
STATIC MP_DEFINE_CONST_DICT(MP_VFS_LFSx(file_locals_dict), MP_VFS_LFSx(file_locals_dict_table));
#if MICROPY_PY_IO_FILEIO
STATIC const mp_stream_p_t MP_VFS_LFSx(fileio_stream_p) = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = MP_VFS_LFSx(file_read),
.write = MP_VFS_LFSx(file_write),
.ioctl = MP_VFS_LFSx(file_ioctl),
};
const mp_obj_type_t MP_TYPE_VFS_LFSx_(_fileio) = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_EXTENDED,
.name = MP_QSTR_FileIO,
.print = MP_VFS_LFSx(file_print),
.locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(file_locals_dict),
MP_TYPE_EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &MP_VFS_LFSx(fileio_stream_p),
),
};
#endif
STATIC const mp_stream_p_t MP_VFS_LFSx(textio_stream_p) = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
.read = MP_VFS_LFSx(file_read),
.write = MP_VFS_LFSx(file_write),
.ioctl = MP_VFS_LFSx(file_ioctl),
.is_text = true,
};
const mp_obj_type_t MP_TYPE_VFS_LFSx_(_textio) = {
{ &mp_type_type },
.flags = MP_TYPE_FLAG_EXTENDED,
.name = MP_QSTR_TextIOWrapper,
.print = MP_VFS_LFSx(file_print),
.locals_dict = (mp_obj_dict_t *)&MP_VFS_LFSx(file_locals_dict),
MP_TYPE_EXTENDED_FIELDS(
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &MP_VFS_LFSx(textio_stream_p),
),
};
|
#ifndef INDIVIDUO_H
#define INDIVIDUO_H
void inserirIndividuo();
int buscarIndividuo(char *id);
void removerIndividuo();
#endif
|
/**
* 5. Crie um programa que defina e imprima a seguinte matriz:
*
* {
* { 'I', 'F', 'S', 'P' },
* { '2', '0', '1', '6' }
* }
*/
#include<stdio.h>
int main()
{
int i, j;
char matriz[2][4] =
{
{ 'I', 'F', 'S', 'P' },
{ '2', '0', '1', '6' }
};
for(i = 0; i < 2; i++)
{
for(j = 0; j < 4; j++)
{
printf("%c", matriz[i][j]);
}
printf("\n");
}
getchar();
return 0;
}
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omp.h>
#include <complex.h>
#define spIndType long long
#define spValType float complex
void applyHybridKaczmarz(spIndType *rowptr , spValType *valA ,spIndType *colA, long long numDomains, long long domainLength ,
unsigned int *ArrIdxs, spValType *x, spValType *b, spValType *invD,long long numit, long long numCores){
omp_set_num_threads(numCores);
#pragma omp parallel shared(x,b,rowptr,valA,colA,invD,numit,ArrIdxs)
{
int domain;
unsigned int row;
spIndType k,i,gIdx;
double complex inner;
for (k=0 ; k < numit ; ++k){
#pragma omp for
for (domain=0 ; domain < numDomains ; ++domain){
for (i=0 ; i < domainLength ; ++i){
row = ArrIdxs[domain*domainLength + i];
if (row > 0){
inner = b[row-1];
for (gIdx = rowptr[row-1]-1; gIdx < rowptr[row]-1; ++gIdx){
// gIdx is in C indices here...
inner -= conj(valA[gIdx])*x[colA[gIdx]-1];
}
inner*=invD[row-1];
for (gIdx = rowptr[row-1]-1; gIdx < rowptr[row]-1; ++gIdx){
// gIdx is in C indices here...
x[colA[gIdx]-1] += inner*valA[gIdx];
}
}
}
}
}
}
return;
}
|
#include <stdio.h>
int main()
{
float num1, num2, result;
char op;
printf("Enter your operation\n");
scanf("%f %c %f", &num1, &op, &num2);
switch (op)
{
case '-':
result = num1 - num2;
printf("Result: %.2f", result);
break;
case '+':
result = num1 + num2;
printf("Result: %.2f", result);
break;
case '*':
result = num1 * num2;
printf("Result: %.2f", result);
break;
case '/':
result = num1 / num2;
printf("Result: %.2f", result);
break;
default:
printf("The operation is not valid");
break;
}
return 0;
}
|
#include <stdio.h>
void welcome(void)
{
printf("---=== Grocery Inventory System ===---\n\n");
}
void prnTitle(void)
{
printf("Row |SKU| Name | Price |Taxed| Qty | Min | Total |Atn\n");
printf("----+---+--------------------+--------+-----+-----+-----+------------|---\n");
}
void prnFooter(double gTotal)
{
printf("--------------------------------------------------------+----------------\n");
if(gTotal > 0)
printf(" Grand Total: |%12.2lf\n",gTotal);
}
void clrKyb(void)
{
char character;
do {
scanf("%c",&character);
}
while(character != '\n');
}
void pause(void)
{
printf("Press <ENTER> to continue...");
clrKyb();
}
int getInt(void)
{
char NL = 'x';
int value;
while (NL != '\n')
{
scanf("%d%c",&value,&NL);
if (NL != '\n')
{
clrKyb();
printf("Invalid integer, please try again: ");
}
}
return value;
}
double getDbl(void)
{
char NL = 'x';
double value;
while (NL != '\n')
{
scanf("%lf%c",&value,&NL);
if (NL != '\n')
{
clrKyb();
printf("Invalid number, please try again: ");
}
}
return value;
}
int getIntLimited(int lowerLimit, int upperLimit)
{
int value;
do {
value = getInt();
if (value < lowerLimit || value > upperLimit)
{
printf("Invalid value, %d < value < %d: ",lowerLimit,upperLimit);
}
}
while (value < lowerLimit || value >upperLimit);
return value;
}
double getDblLimited(double lowerLimit, double upperLimit)
{
double value;
do {
value = getDbl();
if (value < lowerLimit || value > upperLimit)
{
printf("Invalid value, %lf< value < %lf: ",lowerLimit,upperLimit);
}
}
while (value < lowerLimit || value > upperLimit);
return value;
}
int main(void) {
int iVal;
double dVal;
welcome(); //welcome message
printf("listing header and footer with grand total:\n");
prnTitle(); //print title
prnFooter(1234.5678); //print footer
printf("listing header and footer without grand total:\n");
prnTitle(); //print title
prnFooter(-1); //print footer
pause(); //waiting for <Enter>
printf("Enter an integer: ");
iVal = getInt(); //get Integer
printf("You entered: %d\n", iVal);
printf("Enter an integer between 10 and 20: ");
iVal = getIntLimited(10, 20); //get integer from range
printf("Your entered %d\n", iVal);
printf("Enter a floating point number: ");
dVal = getDbl(); //get floating point number
printf("You entered: %0.2lf\n", dVal);
printf("Enter a floating point number between 10.00 and 20.00: ");
dVal = getDblLimited(10.0, 20.0); //get floating point number from range
printf("You entered: %0.2lf\n", dVal);
printf("End of tester program for milestone one!\n");
return 0;
}
|
#include "min_unit.h"
#include "common.h"
#include "tests_common.h"
#include <stdlib.h>
#include <stdio.h>
#ifdef _WIN32
#include <process.h>
#endif
char* test_cell_type_is_player_owned()
{
mu_assert(!cell_type_is_player_owned(GROUND));
mu_assert(!cell_type_is_player_owned(WATER));
mu_assert(!cell_type_is_player_owned(ROCK));
mu_assert(cell_type_is_player_owned(HEADQUARTER));
mu_assert(!cell_type_is_player_owned(BRIDGE));
mu_assert(cell_type_is_player_owned(UNIT_1));
mu_assert(cell_type_is_player_owned(UNIT_2));
mu_assert(cell_type_is_player_owned(UNIT_3));
return 0;
}
char* test_cell_type_is_unit() {
mu_assert(!cell_type_is_unit(GROUND));
mu_assert(!cell_type_is_unit(WATER));
mu_assert(!cell_type_is_unit(ROCK));
mu_assert(!cell_type_is_unit(HEADQUARTER));
mu_assert(!cell_type_is_unit(BRIDGE));
mu_assert(cell_type_is_unit(UNIT_1));
mu_assert(cell_type_is_unit(UNIT_2));
mu_assert(cell_type_is_unit(UNIT_3));
return 0;
}
char* test_pos_init() {
int i, j;
for (i = 0; i <= 10; i++) {
for (j = 0; j <= 10; j++) {
/*printf("\n%d,%d", i, j);*/
Pos pos = pos_init(i, j);
/*test niet per se nodig*/
//mu_assert(pos.row == i && pos.col == j);
mu_assert((&pos) != NULL);
}
}
return 0;
}
char* test_path_alloc() {
unsigned int i, j;
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
Path* path = path_alloc(i, j);
/*test niet per se nodig*/
//mu_assert(path->step_count == i && path->distance == j && (&(path->steps)) != NULL);
mu_assert(path != NULL);
}
}
return 0;
}
char* test_path_free() {
Path* path = path_alloc(1, 1);
path_free(&path);
mu_assert(path == NULL);
return 0;
}
|
/*
* TestLCD.c
*
* Created: 11/14/2014 12:07:54 PM
* Author: saida
*/
/*
* LCD_Atmel1.c
*
* Created: 10/24/2014 3:29:51 PM
* Author: LuisDavid
* still a alpha Version 0.2
*/
// CARLOS:
// FROM LCD_Atmel.h you there is a line you can modify at will
// to change how the cursor looks like
#define F_CPU 8000000UL // 1MHz internal clock speed of ATmega328
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <util/twi.h>
#include "TWI_Master.h"
#include "TestLCD_H.h"
void LCD_LONG_MEM_WRITE();
void init_lcd();
void LCD_SINGLE_MEM_WRITE (unsigned char BYTE);
int main(void)
{
unsigned char single[1];
//all steps to initialize and timings
init_lcd();
// store and send one char at the time using Display single
single[0] = 'L';
Display_Single(single);
single[0] = 'U';
Display_Single(single);
single[0] = 'I';
Display_Single(single);
single[0] = 'S';
Display_Single(single);
single[0] = 'A';
Display_Single(single);
single[0] = 'N';
Display_Single(single);
single[0] = 'D';
Display_Single(single);
_delay_ms(500);
// changes the cursor address to the second line
// no need to fill the line
Second_Line();
// same sequence as above one char at a time
single[0] = 'R';
Display_Single(single);
single[0] = 'Y';
Display_Single(single);
single[0] = 'A';
Display_Single(single);
single[0] = 'N';
Display_Single(single);
single[0] = '!';
Display_Single(single);
_delay_ms(1000);
// Clear and bring cursor to 0,0
Clear_Screen();
// Display message
Display_Home_Msg ();
_delay_ms(2000);
Display_Up_Arrow_Wr ();
_delay_ms(2000);
Display_Down_Arrow_Wr ();
// _delay_ms(1000);
// only to know I was done Ignore
while(1)
{
PORTB |= (1<<PORTB1); //turn blue LED on to signify we are in at home screen
_delay_ms(500);
PORTB &= ~(1<<PORTB1); //turn red LED off
_delay_ms(500);
}
return 0;
}
|
#include <stdio.h>
typedef struct _var {
int v, n;
} var;
// функция подсчёта повторений
var* cnt_moda(const int* f, const int* l, var* v) {
var* p, * n;
for (n = v; f != l; ++f) {
for (p = v; (p != n) && (p->v != *f); ++p);
p->v = *f;
p->n++;
if (p >= n)
++n;
}
return v + (n - v);
}
// функция возвращает максимум повторений
int max_moda(const var* f, const var* l) {
int m = f->n;
while (f != l) {
if (f->n > m)
m = f->n;
++f;
}
return m;
}
int main(void)
{
int mas[] = { 8872, 10044, 7590, 6068, 6086, 5840, 5768, 5738, 5826, 5654, 5376, 5698, 5726, 5630, 5618, 5668, 5444, 5686, 5670, 5434, 5478, 5514, 5442, 5676, 5664, 5592, 5708, 5700, 5660, 5500, 5746, 5416, 5676, 5726, 5578, 5654, 5608, 5662, 5720, 9180 };
int cnt, i = 0;
float aver = 0;
var vs[40] = { 0 };
var* it, * end;
end = cnt_moda(mas, mas + sizeof(mas) / sizeof(mas[0]), vs);
cnt = max_moda(vs, end);
for (it = vs; it != end; ++it) {
if (it->n == cnt)
{
printf("moda: %d\n", it->v);
aver += it->v;
i++;
}
}
aver /= i;
printf("%f", aver);
return 0;
}
|
#include <std.h>
#include <marsh.h>
inherit MONSTER;
void create() {
::create();
set_gender("female");
set_name("fish");
set_id( ({ "rainbow","rainbow trout","fish"}) );
set_short("A rainbow trout");
set_long("The colors of the rainbow are brightly displayed on the side of this fish.");
set_level(20);
set_body_type("fish");
set_alignment(10);
set_race("fish");
set_class("fighter");
}
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/mman.h>
#include "ocelot.h"
#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
__LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
typedef enum {
SYMREG_COMPONENTS_TGT,
SYMREG_COMPONENTS_GRP,
SYMREG_COMPONENTS_REG,
SYMREG_COMPONENTS_LAST
} symreg_components_t;
typedef enum {
SYMREG_QUERY_SZ,
SYMREG_QUERY_QUERY,
SYMREG_QUERY_READ,
SYMREG_QUERY_LAST
} symreg_query_t;
int fd = -1;
unsigned long phys;
void *map_base;
static unsigned long read_reg(unsigned long addr) {
if (fd < 0)
if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
if (addr < phys || addr >= (phys + MAP_SIZE)) {
if (phys)
if(munmap(map_base, MAP_SIZE) == -1) FATAL;
} else {
return *((unsigned long *) (map_base + addr - phys));
}
fflush(stdout);
phys = addr & ~MAP_MASK;
map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, phys);
if(map_base == (void *) -1) FATAL;
return *((unsigned long *) (map_base + addr - phys));
}
struct component_info {
int idx;
int repl;
};
static int find_target(struct component_info *info, char *pattern)
{
int t;
for (t = 0; vtss_symreg_targets[t].name; t++) {
int repl = info[SYMREG_COMPONENTS_TGT].repl;
if (repl >=0 && repl != vtss_symreg_targets[t].repl_number)
continue;
if (!strcmp(pattern, vtss_symreg_targets[t].name))
break;
}
if (!vtss_symreg_targets[t].name)
return -1;
info[SYMREG_COMPONENTS_TGT].idx = t;
return 0;
}
static int find_grp(struct component_info *info, char *pattern)
{
int t = info[SYMREG_COMPONENTS_TGT].idx;
const vtss_symreg_reggrp_t *groups;
int g;
groups = vtss_symreg_targets[t].reggrps;
for (g = 0; groups[g].name; g++) {
if (!strcmp(pattern, groups[g].name))
break;
}
if (!groups[g].name)
return -1;
info[SYMREG_COMPONENTS_GRP].idx = g;
return 0;
}
static int find_reg(struct component_info *info, char *pattern)
{
int t = info[SYMREG_COMPONENTS_TGT].idx;
int g = info[SYMREG_COMPONENTS_GRP].idx;
int r;
const vtss_symreg_target_t *tgt = &vtss_symreg_targets[t];
const vtss_symreg_reggrp_t *grp = &tgt->reggrps[g];
const vtss_symreg_reg_t *regs = grp->regs;
for (r = 0; regs[r].name; r++) {
if (!strcmp(pattern, regs[r].name))
break;
}
if (!regs[r].name)
return -1;
info[SYMREG_COMPONENTS_REG].idx = r;
return 0;
}
static int find_component(struct component_info *info, int i, char *pattern)
{
switch (i) {
case SYMREG_COMPONENTS_TGT:
return find_target(info, pattern);
break;
case SYMREG_COMPONENTS_GRP:
return find_grp(info, pattern);
break;
case SYMREG_COMPONENTS_REG:
return find_reg(info, pattern);
break;
}
return -1;
}
static int match_regs(char *pattern, struct component_info *info)
{
int i;
char *str1 = pattern, *str2;
size_t cnt;
for (i = 0; i < SYMREG_COMPONENTS_LAST; i++) {
info[i].idx = -1;
info[i].repl = -1;
}
for (i = 0; i < SYMREG_COMPONENTS_LAST; i++) {
if (str1 == NULL) {
break;
}
str2 = strstr(str1, ":");
if (str2) {
if (i == SYMREG_COMPONENTS_REG)
return -1;
cnt = str2 - str1;
} else {
cnt = strlen(str1);
}
if (str2)
*str2 = '\0';
if (cnt > 0) {
if (str1[cnt-1] == ']') {
char *b_end = &str1[cnt - 1];
char *b_start = b_end;
while (b_start > str1) {
if (*b_start == '[')
break;
b_start--;
}
if (b_start == str1)
return -1;
*b_start++ = '\0';
*b_end = '\0';
info[i].repl = strtoul(b_start, NULL, 10);
}
if (find_component(info, i, str1))
return -1;
}
if (str2)
str1 = str2 + 1;
else
str1 = NULL;
}
return 0;
}
static void print_regr(struct component_info *info, int *max_width, int query)
{
int t = info[SYMREG_COMPONENTS_TGT].idx;
int g = info[SYMREG_COMPONENTS_GRP].idx;
int gr = info[SYMREG_COMPONENTS_GRP].repl;
int r = info[SYMREG_COMPONENTS_REG].idx;
int rr = info[SYMREG_COMPONENTS_REG].repl;
const vtss_symreg_target_t *tgt = &vtss_symreg_targets[t];
const vtss_symreg_reggrp_t *grp = &tgt->reggrps[g];
const vtss_symreg_reg_t *reg = &grp->regs[r];
unsigned int addr;
char name[256];
char grptmp[50];
const char *grpname = grptmp;
char tgttmp[50];
const char *tgtname = tgttmp;
if (grp->repl_cnt > 1)
snprintf(grptmp, sizeof(grptmp), "%s[%u]", grp->name, gr);
else
grpname = grp->name;
if (tgt->repl_number >= 0)
snprintf(tgttmp, sizeof(tgttmp), "%s[%u]", tgt->name, tgt->repl_number);
else
tgtname = tgt->name;
addr = tgt->base_addr + (grp->base_addr << 2) + gr * 4 * grp->repl_width + (reg->addr + rr) * 4;
if (reg->repl_cnt > 1)
snprintf(name, sizeof(name), "%s:%s:%s[%u]", tgtname, grpname, reg->name, rr);
else
snprintf(name, sizeof(name), "%s:%s:%s", tgtname, grpname, reg->name);
if (query == SYMREG_QUERY_SZ) {
int len = strlen(name);
if (len > *max_width)
*max_width = len;
return;
}
if (query == SYMREG_QUERY_QUERY)
printf("%-*s 0x%08x\n", *max_width, name, addr);
else {
unsigned int v = read_reg(addr);
int j;
printf("%-*s 0x%08x %10u ", *max_width, name, v, v);
for (j = 31; j >= 0; j--) {
printf("%d%s", v & (1 << j) ? 1 : 0, j == 0 ? "\n" : (j % 4) ? "" : ".");
}
}
}
static int print_reg(struct component_info *info, int *max_width, int query)
{
int t = info[SYMREG_COMPONENTS_TGT].idx;
int g = info[SYMREG_COMPONENTS_GRP].idx;
int r = info[SYMREG_COMPONENTS_REG].idx;
const vtss_symreg_target_t *tgt = &vtss_symreg_targets[t];
const vtss_symreg_reggrp_t *grp = &tgt->reggrps[g];
const vtss_symreg_reg_t *reg = &grp->regs[r];
int repl = info[SYMREG_COMPONENTS_REG].repl;
int rp;
if (repl < 0) {
for (rp = 0; rp < reg->repl_cnt; rp++) {
info[SYMREG_COMPONENTS_REG].repl = rp;
print_regr(info, max_width, query);
}
info[SYMREG_COMPONENTS_REG].repl = -1;
} else {
print_regr(info, max_width, query);
}
return 0;
}
static int print_grpr(struct component_info *info, int *max_width, int query)
{
int t = info[SYMREG_COMPONENTS_TGT].idx;
int g = info[SYMREG_COMPONENTS_GRP].idx;
const vtss_symreg_target_t *tgt = &vtss_symreg_targets[t];
const vtss_symreg_reggrp_t *grp = &tgt->reggrps[g];
const vtss_symreg_reg_t *regs = grp->regs;
if (info[SYMREG_COMPONENTS_REG].idx < 0) {
int r;
for (r = 0; regs[r].name; r++) {
info[SYMREG_COMPONENTS_REG].idx = r;
info[SYMREG_COMPONENTS_REG].repl = -1;
print_reg(info, max_width, query);
}
info[SYMREG_COMPONENTS_REG].idx = -1;
} else {
print_reg(info, max_width, query);
}
return 0;
}
static int print_grp(struct component_info *info, int *max_width, int query)
{
int t = info[SYMREG_COMPONENTS_TGT].idx;
int g = info[SYMREG_COMPONENTS_GRP].idx;
const vtss_symreg_target_t *tgt = &vtss_symreg_targets[t];
const vtss_symreg_reggrp_t *grp = &tgt->reggrps[g];
int repl = info[SYMREG_COMPONENTS_GRP].repl;
int rp;
if (repl < 0) {
for (rp = 0; rp < grp->repl_cnt; rp++) {
info[SYMREG_COMPONENTS_GRP].repl = rp;
print_grpr(info, max_width, query);
}
info[SYMREG_COMPONENTS_GRP].repl = -1;
} else {
print_grpr(info, max_width, query);
}
return 0;
}
static int print_target(struct component_info *info, int *max_width, int query)
{
const vtss_symreg_reggrp_t *groups;
int t, g;
t = info[SYMREG_COMPONENTS_TGT].idx;
groups = vtss_symreg_targets[t].reggrps;
if (info[SYMREG_COMPONENTS_GRP].idx < 0) {
for (g = 0; groups[g].name; g++) {
info[SYMREG_COMPONENTS_GRP].idx = g;
info[SYMREG_COMPONENTS_GRP].repl = -1;
print_grp(info, max_width, query);
}
info[SYMREG_COMPONENTS_GRP].idx = -1;
} else {
print_grp(info, max_width, query);
}
return 0;
}
static int print_targets(struct component_info *info, int *max_width, int query)
{
int tgt;
if (query == SYMREG_QUERY_QUERY)
printf("%-*s %-10s\n", *max_width, "Register", "Address");
else if (query == SYMREG_QUERY_READ)
printf("%-*s %-10s %-10s 31 24 23 16 15 8 7 0\n", *max_width, "Register", "Value", "Decimal");
tgt = info[SYMREG_COMPONENTS_TGT].idx;
if (info[SYMREG_COMPONENTS_TGT].repl < 0) {
int t;
for (t = tgt; !strcmp(vtss_symreg_targets[t].name, vtss_symreg_targets[tgt].name) ; t++) {
info[SYMREG_COMPONENTS_TGT].idx = t;
print_target(info, max_width, query);
}
info[SYMREG_COMPONENTS_TGT].idx = tgt;
} else {
print_target(info, max_width, query);
}
return 0;
}
int main(int argc, char **argv) {
int query = SYMREG_QUERY_QUERY;
struct component_info info[SYMREG_COMPONENTS_LAST];
int max_width = 0;
if(argc < 3) {
fprintf(stderr, "\nUsage:\t%s <read|query> <target>\n"
"\ttarget : name of the target to dump\n",
argv[0]);
exit(1);
}
if (!strcmp(argv[1], "read"))
query = SYMREG_QUERY_READ;
if (match_regs(argv[2], info))
exit(1);
print_targets(info, &max_width, SYMREG_QUERY_SZ);
print_targets(info, &max_width, query);
close(fd);
return 0;
}
|
/*--------------------------------------------------------------------------*/
/* */
/* comp2.c */
/* 23/04/2021 */
/* */
/* This is a full compiler performing syntax and semantic error */
/* detection and code generation for the CPL language, including */
/* procedure definitions. */
/* */
/* Authors: Ronan Keaveney, Charlie Gorey O'Neill, */
/* Conor Cosgrave, Emmett Lawlor */
/* */
/* */
/*--------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "global.h"
#include "scanner.h"
#include "line.h"
#include "code.h"
#include "debug.h"
#include "sets.h"
#include "strtab.h"
#include "symbol.h"
/*--------------------------------------------------------------------------*/
/* */
/* Global variables used by this parser. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE FILE *InputFile; /* CPL source comes from here. */
PRIVATE FILE *ListFile; /* For nicely-formatted syntax errors. */
PRIVATE FILE *CodeFile; /* machine code output file */
PRIVATE TOKEN CurrentToken; /* Parser lookahead token. Updated by */
/* routine Accept (below). Must be */
/* initialised before parser starts. */
PRIVATE int Read;
PRIVATE int scope;
PRIVATE int Write;
PRIVATE int VarLctn;
PRIVATE int FlagError;
/*---------------------------------------------------------------------------
Declare Sets
----------------------------------------------------------------------------*/
PRIVATE SET StatementFS_aug, StatementFBS, ProgProcDecSet1, ProgProcDecSet2;
PRIVATE SET BlockSet1;
PRIVATE SET FB_Prog, FB_ProcDec, FB_Block;
PRIVATE SET StatementFS_aug2, StatementFBS2;
/*--------------------------------------------------------------------------*/
/* */
/* Function prototypes */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseProgram( void );
PRIVATE int ParseDeclarations( void );
PRIVATE void ParseProcDeclaration( void );
PRIVATE void ParseParameterList( void );
PRIVATE void ParseFormalParameter( void );
PRIVATE void ParseBlock( void );
PRIVATE void ParseStatement( void );
PRIVATE void ParseSimpleStatement( void );
PRIVATE void ParseRestOfStatement( SYMBOL *target );
PRIVATE void ParseProcCallList( void );
PRIVATE void ParseAssignment( void );
PRIVATE void ParseActualParameter( void );
PRIVATE void ParseWhileStatement( void );
PRIVATE void ParseIfStatement( void );
PRIVATE void ParseReadStatement( void );
PRIVATE void ParseWriteStatement( void );
PRIVATE void ParseExpression( void );
PRIVATE void ParseCompoundTerm( void );
PRIVATE void ParseTerm( void );
PRIVATE void ParseSubTerm( void );
PRIVATE void ParseAddOp( void );
PRIVATE void ParseMultOp( void );
PRIVATE void SetupSets( void );
PRIVATE void Synchronise( SET *F, SET*FB );
PRIVATE void Accept( int code );
PRIVATE void ReadToEndOfFile( void );
PRIVATE void ParseIntConst(void);
PRIVATE void ParseIdentifier(void);
PRIVATE void ParseVariable(void);
PRIVATE int ParseBooleanExpression( void );
PRIVATE int ParseRelOp( void );
PRIVATE int OpenFiles( int argc, char *argv[] );
PRIVATE void MakeSymbolTableEntry(int symtype);
PRIVATE SYMBOL *LookupSymbol();
/*--------------------------------------------------------------------------*/
/* */
/* Main: Smallparser entry point. Sets up parser globals (opens input and */
/* output files, initialises current lookahead), then calls */
/* "ParseProgram" to start the parse. */
/* */
/*--------------------------------------------------------------------------*/
PUBLIC int main ( int argc, char *argv[] )
{
Write=0;
Read = 0;
scope = 1;
FlagError=0;
VarLctn = 0;
if ( OpenFiles( argc, argv ) )
{
InitCharProcessor( InputFile, ListFile );
InitCodeGenerator(CodeFile); /*Initialize code generation*/
CurrentToken = GetToken();
SetupSets();
ParseProgram();
WriteCodeFile(); /*Write out assembly to file*/
fclose( InputFile );
fclose( ListFile );
if(FlagError)
{
printf("Syntax Error Detected\n");
return EXIT_FAILURE;
}
printf("Valid, No Errors Detected\n");
return EXIT_SUCCESS;
}
else
{
printf("Syntax Error Dectected\n");
return EXIT_FAILURE;
}
}
/*--------------------------------------------------------------------------*/
/* */
/* SetupSets: This function serves the purpose of initializing all */
/* the sets used for the Primary Augmented S-Algol Error recovery */
/* and resync */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void SetupSets(void){
InitSet(&StatementFS_aug, 6, IDENTIFIER, WHILE, IF, READ, WRITE, END );
InitSet(&StatementFBS, 4, SEMICOLON, ELSE, ENDOFPROGRAM, ENDOFINPUT );
InitSet(&ProgProcDecSet1, 3, VAR, PROCEDURE, BEGIN );
InitSet(&ProgProcDecSet2, 2, PROCEDURE, BEGIN );
InitSet(&BlockSet1, 6, IDENTIFIER, WHILE, IF, READ, WRITE, END);
InitSet(&FB_Prog, 3, ENDOFPROGRAM, ENDOFINPUT, END);
InitSet(&FB_ProcDec, 3, ENDOFPROGRAM, ENDOFINPUT, END);
InitSet(&FB_Block, 4, ENDOFINPUT, ELSE, SEMICOLON, ENDOFPROGRAM );
InitSet(&StatementFS_aug2, 6, IDENTIFIER, WHILE, IF, READ, WRITE, END );
InitSet(&StatementFBS2, 4, SEMICOLON, ELSE, ENDOFPROGRAM, ENDOFINPUT );
}
/*--------------------------------------------------------------------------*/
/* */
/* Synchronise Function: Once the parser encounters a syntax error */
/* this will skip over the error and resync, allowing the parser to */
/* continue parsing the program */
/* */
/* Inputs: F = Augmented First Set */
/* FB = Follow Set union Beacons Set */
/* */
/* Outputs: S = F union FB */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void Synchronise(SET *F, SET *FB){
SET S;
S = Union( 2, F, FB );
if( !InSet( F, CurrentToken.code ) )
{
SyntaxError2( *F, CurrentToken );
while( !InSet( &S, CurrentToken.code ) )
CurrentToken = GetToken();
}
}
/*--------------------------------------------------------------------------*/
/* */
/* Parser routines: Recursive-descent implementaion of the grammar's */
/* productions. */
/* */
/* */
/* ParseProgram implements: */
/* */
/* <Program> :== "PROGRAM" <Identifier> ";" */
/* [ <Declarations> ] {<ProcDeclaration>} */
/* <Block> "." */
/* */
/* Sync Points before [<Declarations>] */
/* before and immediatley after [<ProcDeclarations>] */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseProgram(void)
{
Accept(PROGRAM);
Accept(IDENTIFIER);
Accept(SEMICOLON);
MakeSymbolTableEntry(STYPE_PROGRAM);
/* Synchronise ParseProgramSet1, Followers, Beacons */
Synchronise( &ProgProcDecSet1, &FB_Prog );
if ( CurrentToken.code == VAR ) ParseDeclarations();
/* Synchronise ParseProgramSet2, Followers, Beacons */
Synchronise( &ProgProcDecSet2, &FB_Prog );
/* Recursive ProcDeclaration */
while (CurrentToken.code == PROCEDURE )
{
ParseProcDeclaration();
/* Synchronise ParseProgramSet2, Followers, Beacons */
Synchronise( &ProgProcDecSet2, &FB_Prog );
}
ParseBlock();
Accept( ENDOFPROGRAM );
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseDeclararions implements: */
/* */
/* <Declarations> :== "VAR" <Variable> { "," <Variable> } ";" */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE int ParseDeclarations(void)
{
int VarCounter = 0;
Accept( VAR );
MakeSymbolTableEntry(STYPE_VARIABLE);
Accept( IDENTIFIER );
ParseVariable();
VarCounter++;
while (CurrentToken.code == COMMA)
{
Accept(COMMA);
MakeSymbolTableEntry(STYPE_VARIABLE);
Accept( IDENTIFIER );
ParseVariable();
VarCounter++;
}
Accept(SEMICOLON);
return VarCounter;
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseProcDeclararion implements: */
/* */
/* <ProcDeclaration> :== "PROCEDURE" <Identifier> */
/* [<ParameterList>] ";" [<Declarations>] */
/* {<ProcDeclaration>} <Block> ";" */
/* */
/* Sync Points before [<Declarations>] */
/* before and immediatley after [<ProcDeclarations>] */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseProcDeclaration(void)
{
int VarCounter = 0;
int Add;
SYMBOL *procedure;
scope++;
if ( CurrentToken.code == LEFTPARENTHESIS )
{
ParseParameterList();
}
Accept( SEMICOLON );
Synchronise( &ProgProcDecSet1, &FB_ProcDec );
if ( CurrentToken.code == VAR )
{
ParseDeclarations();
}
Synchronise( &ProgProcDecSet2, &FB_ProcDec );
while ( CurrentToken.code == PROCEDURE )
ParseProcDeclaration();
Synchronise( &ProgProcDecSet2, &FB_ProcDec );
ParseBlock();
Accept( SEMICOLON );
RemoveSymbols( scope );
scope--;
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseParameterList implements: */
/* */
/* <ParameterList> :== "(" <FormalParameter> { "," */
/* <FormalParameter> } ")" */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseParameterList(void)
{
Accept( LEFTPARENTHESIS );
ParseFormalParameter();
while (CurrentToken.code == COMMA)
{
Accept(COMMA);
ParseFormalParameter();
}
Accept(RIGHTPARENTHESIS);
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseFormalParameter implements: */
/* */
/* <FormalParameter> :== [ "REF" ] <Variable> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseFormalParameter(void)
{
if(CurrentToken.code == REF){
MakeSymbolTableEntry(STYPE_REFPAR);
Accept(REF);
}
MakeSymbolTableEntry(STYPE_VARIABLE);
ParseVariable();
Accept( IDENTIFIER );
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseBlock implements: */
/* */
/* <Block> :== "BEGIN" { <Statement> ";" } "END" */
/* */
/* Sync Points before and immediatley after [<Statement>] */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseBlock(void)
{
Accept(BEGIN);
Synchronise(&StatementFS_aug,&StatementFBS);
Synchronise( &BlockSet1, &FB_Block );
while (CurrentToken.code == IDENTIFIER || CurrentToken.code == WHILE ||
CurrentToken.code == IF || CurrentToken.code == READ ||
CurrentToken.code == WRITE)
{
ParseStatement();
Accept(SEMICOLON);
Synchronise( &StatementFS_aug, &StatementFBS );
Synchronise( &BlockSet1, &FB_Block );
}
Accept(END);
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseStatement implements: */
/* */
/* <Statement> :== <SimpleStatement> | <WhileStatement> | */
/* <IfStatement> | <ReadStatement> | */
/* <WriteStatement> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseStatement( void )
{
if ( CurrentToken.code == IDENTIFIER ) ParseSimpleStatement();
else if ( CurrentToken.code == WHILE ) ParseWhileStatement();
else if ( CurrentToken.code == IF ) ParseIfStatement();
else if ( CurrentToken.code == READ ) ParseReadStatement();
else if ( CurrentToken.code == WRITE ) ParseWriteStatement();
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseSimpleStatement implements: */
/* */
/* <SimpleStatement> :== <VarOrProcName> <RestOfStatement> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseSimpleStatement( void )
{
SYMBOL *target;
target = LookupSymbol();
Accept( IDENTIFIER );
ParseRestOfStatement( target );
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseRestOfStatement implements: */
/* */
/* <RestOfStatement> :== <ProcCallList> | <Assignment> | EPSILON */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseRestOfStatement( SYMBOL *target )
{
switch ( CurrentToken.code )
{
case LEFTPARENTHESIS :
ParseProcCallList();
case SEMICOLON :
if ( target != NULL && target->type == STYPE_PROCEDURE )
Emit ( I_CALL, target->address );
else
{
Error( "Not a procedure\n", CurrentToken.pos );
KillCodeGeneration();
}
break;
case ASSIGNMENT :
default :
ParseAssignment();
if ( target != NULL && target->type == STYPE_VARIABLE )
Emit ( I_STOREA, target->address );
else
{
Error( "Undeclared variable\n", CurrentToken.pos );
KillCodeGeneration();
}
break;
}
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseProcCallList implements: */
/* */
/* <ProcCallList> :== "(" <ActualParameter> { "," */
/* <ActualParameter> } ")" */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseProcCallList( void )
{
Accept( LEFTPARENTHESIS );
ParseActualParameter();
while ( CurrentToken.code == COMMA ) {
Accept( COMMA );
ParseActualParameter();
}
Accept( RIGHTPARENTHESIS );
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseAssignment implements: */
/* */
/* <Assignment> :== ":=" <Expression> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseAssignment(void)
{
Accept(ASSIGNMENT);
ParseExpression();
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseActualParameter implements: */
/* */
/* <ActualParameter> :== <Variable> | <Expression> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseActualParameter( void )
{
if ( CurrentToken.code == IDENTIFIER ) Accept( IDENTIFIER );
else ParseExpression();
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseWhileStatement implements: */
/* */
/* <WhileStatement> :== "WHILE" <BooleanExpression> "DO" <Block> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseWhileStatement(void)
{
int Label1, Label2, L2BackPatchLoc;
Accept( WHILE );
Label1 = CurrentCodeAddress();
L2BackPatchLoc = ParseBooleanExpression();
Accept( DO );
ParseBlock();
Emit(I_BR, Label1);
Label2 = CurrentCodeAddress();
BackPatch(L2BackPatchLoc, Label2);
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseIfStatement implements: */
/* */
/* <IfStatement> :== "IF" <BooleanExpression> "THEN" */
/* <Block> [ "ELSE" <Block> ] */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseIfStatement(void)
{
int L1BackPatchLoc, L2BackPatchLoc;
Accept( IF );
L1BackPatchLoc = ParseBooleanExpression();
Accept( THEN );
ParseBlock();
if ( CurrentToken.code == ELSE )
{
L2BackPatchLoc = CurrentCodeAddress();
Emit( I_BR, 999 ); // Branch to TEMP code address,
// to be backpatched later
BackPatch( L1BackPatchLoc, CurrentCodeAddress() );
Accept( ELSE );
ParseBlock();
BackPatch( L2BackPatchLoc, CurrentCodeAddress() );
}
else
BackPatch( L1BackPatchLoc, CurrentCodeAddress() );
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseReadStatement implements: */
/* */
/* <ReadStatement> :== "READ" "(" <Variable> { "," */
/* <Variable> } ")" */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseReadStatement(void)
{
Accept(READ);
Accept( LEFTPARENTHESIS );
Accept( IDENTIFIER );
Read = 1;
ParseProcCallList();
Read = 0;
while (CurrentToken.code == COMMA )
{
Accept( COMMA );
Accept( IDENTIFIER );
}
Accept( RIGHTPARENTHESIS );
_Emit(I_READ);
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseWriteStatement implements: */
/* */
/* <WriteStatement> :== "WRITE" "(" <Expression> { "," */
/* <Expression> } ")" */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseWriteStatement(void)
{
Accept( WRITE );
Accept( LEFTPARENTHESIS );
ParseExpression();
Write = 1;
ParseProcCallList();
while (CurrentToken.code == COMMA ) {
Accept( COMMA );
ParseExpression();
}
Accept( RIGHTPARENTHESIS );
_Emit(I_WRITE);
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseExpression implements: */
/* */
/* <Expression> :== <CompoundTerm> { <AddOp> <CompoundTerm> } */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseExpression(void)
{
int op;
ParseCompoundTerm();
while ( (op = CurrentToken.code) == ADD || /* ADD: name for "+". */
op == SUBTRACT ) /* SUBTRACT: "-". */
{
ParseAddOp();
ParseCompoundTerm();
if(op == ADD) _Emit(I_ADD); else _Emit(I_SUB);
}
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseCompoundTerm implements: */
/* */
/* <CompoundTerm> :== <Term> { <MultOp> <Term> } */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseCompoundTerm( void )
{
int token;
ParseTerm();
while ( (token = CurrentToken.code) == MULTIPLY ||
token == DIVIDE ) {
ParseMultOp();
ParseTerm();
if(token == MULTIPLY) _Emit( I_MULT );
else _Emit( I_DIV );
}
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseTerm implements: */
/* */
/* <Term> :== ["-"] <SubTerm> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseTerm( void )
{
int negateflag = 0;
if ( CurrentToken.code == SUBTRACT ) {
negateflag = 1;
Accept( SUBTRACT );
}
ParseSubTerm();
if(negateflag) _Emit(I_NEG);
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseTerm implements: */
/* */
/* <BooleanExpression> :== <Expression> <RelOp> <Expression> */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE int ParseBooleanExpression(void)
{
int BackPatchAddr, RelOpInstruction;
ParseExpression();
RelOpInstruction = ParseRelOp();
ParseExpression();
_Emit(I_SUB);
ParseRelOp();
BackPatchAddr = CurrentCodeAddress( );
Emit( RelOpInstruction, 0 ); // Branch to TEMP code address,
// to be backpatched later
return BackPatchAddr;
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseSubTerm implements: */
/* */
/* <SubTerm> :== <Variable> | <IntConst> | "(" <Expression> ")" */
/* */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseSubTerm(void)
{
int i, j;
SYMBOL *var;
switch(CurrentToken.code)
{
case INTCONST:
Emit(I_LOADI,CurrentToken.value);
ParseIntConst();
break;
case LEFTPARENTHESIS:
Accept(LEFTPARENTHESIS);
ParseExpression();
Accept(RIGHTPARENTHESIS);
break;
case IDENTIFIER:
default:
var = LookupSymbol();
if(var != NULL && var->type == STYPE_VARIABLE) {
if (Write) {
Emit(I_LOADA,var->address);
}
else if (Read) {
Emit(I_STOREA,var->address);
}
else {
Emit(I_LOADA,var->address);
}
}
else if ( var->type == STYPE_LOCALVAR ) {
j = scope - var->scope;
if ( j == 0 )
Emit( I_LOADFP, var->address );
else {
_Emit( I_LOADFP );
for ( i = 0; i < j - 1; i++ )
_Emit( I_LOADSP );
Emit( I_LOADSP, var->address );
}
}
else printf("Undeclared Name or Variable");
ParseVariable();
break;
}
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseAddOp implements: */
/* */
/* <AddOp> :== "+" | "-" */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseAddOp( void )
{
if ( CurrentToken.code == ADD ) Accept( ADD );
else Accept ( SUBTRACT );
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseMultOp implements: */
/* */
/* <MultOp> :== "*" | "/" */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseMultOp( void )
{
if ( CurrentToken.code == MULTIPLY ) Accept( MULTIPLY );
else Accept ( DIVIDE );
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseRelOp implements: */
/* */
/* <RelOp> :== "=" | "<=" | ">=" | "<" | ">" */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Int RelOpInstruction */
/* */
/* Side Effects: Lookahead token advanced. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE int ParseRelOp( void )
{
int RelOpInstruction;
switch(CurrentToken.code) {
case LESSEQUAL:
RelOpInstruction = I_BG;
Accept(LESSEQUAL);
break;
case GREATEREQUAL:
RelOpInstruction = I_BL;
Accept(GREATEREQUAL);
break;
case LESS:
RelOpInstruction = I_BGZ;
Accept(LESS);
break;
case EQUALITY:
RelOpInstruction = I_BZ;
Accept(EQUALITY);
break;
case GREATER:
RelOpInstruction = I_BLZ;
Accept(GREATER);
break;
}
return RelOpInstruction;
}
/*--------------------------------------------------------------------------*/
/* */
/* End of parser. Support routines follow. */
/* */
/*--------------------------------------------------------------------------*/
/* */
/* Accept: Takes an expected token name as argument, and if the current */
/* lookahead matches this, advances the lookahead and returns. */
/* */
/* If the expected token fails to match the current lookahead, */
/* this routine reports a syntax error and exits ("crash & burn" */
/* parsing). Note the use of routine "SyntaxError" */
/* (from "scanner.h") which puts the error message on the */
/* standard output and on the listing file, and the helper */
/* "ReadToEndOfFile" which just ensures that the listing file is */
/* completely generated. */
/* */
/* */
/* Inputs: Integer code of expected token */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: If successful, advances the current lookahead token */
/* "CurrentToken". */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void Accept( int ExpectedToken )
{
static int recovering = 0;
/* Error re-sync code */
if( recovering )
{
while( CurrentToken.code != ExpectedToken &&
CurrentToken.code != ENDOFINPUT )
CurrentToken = GetToken();
recovering = 0;
}
/* Normal Accept code */
if( CurrentToken.code != ExpectedToken )
{
SyntaxError( ExpectedToken, CurrentToken );
recovering = 1;
}
else CurrentToken = GetToken();
}
/*--------------------------------------------------------------------------*/
/* */
/* OpenFiles: Reads strings from the command-line and opens the */
/* associated input and listing files. */
/* */
/* Note that this routine mmodifies the globals "InputFile" and */
/* "ListingFile". It returns 1 ("true" in C-speak) if the input and */
/* listing files are successfully opened, 0 if not, allowing the caller */
/* to make a graceful exit if the opening process failed. */
/* */
/* */
/* Inputs: 1) Integer argument count (standard C "argc"). */
/* 2) Array of pointers to C-strings containing arguments */
/* (standard C "argv"). */
/* */
/* Outputs: No direct outputs, but note side effects. */
/* */
/* Returns: Boolean success flag (i.e., an "int": 1 or 0) */
/* */
/* Side Effects: If successful, modifies globals "InputFile" and */
/* "ListingFile". */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE int OpenFiles( int argc, char *argv[] )
{
if ( argc != 4 ) {
fprintf( stderr, "%s <inputfile> <listfile>\n", argv[0] );
return 0;
}
if ( NULL == ( InputFile = fopen( argv[1], "r" ) ) ) {
fprintf( stderr, "cannot open \"%s\" for input\n", argv[1] );
return 0;
}
if ( NULL == ( ListFile = fopen( argv[2], "w" ) ) ) {
fprintf( stderr, "cannot open \"%s\" for output\n", argv[2] );
fclose( InputFile );
return 0;
}
if ( NULL == ( CodeFile = fopen( argv[3], "w" ) ) ) {
fprintf( stderr, "cannot open \"%s\" for output\n", argv[3] );
fclose( InputFile );
fclose( ListFile );
return 0;
}
return 1;
}
/*--------------------------------------------------------------------------*/
/* */
/* ReadToEndOfFile: Reads all remaining tokens from the input file. */
/* associated input and listing files. */
/* */
/* This is used to ensure that the listing file refects the entire */
/* input, even after a syntax error (because of crash & burn parsing, */
/* if a routine like this is not used, the listing file will not be */
/* complete. Note that this routine also reports in the listing file */
/* exactly where the parsing stopped. Note that this routine is */
/* superfluous in a parser that performs error-recovery. */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Nothing */
/* */
/* Side Effects: Reads all remaining tokens from the input. There won't */
/* be any more available input after this routine returns. */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ReadToEndOfFile( void )
{
if ( CurrentToken.code != ENDOFINPUT )
{
Error( "Parsing ends here in this program\n", CurrentToken.pos );
while ( CurrentToken.code != ENDOFINPUT ) CurrentToken = GetToken();
}
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseVariable implements: */
/* */
/* <Variable> :== <Identifier> */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseVariable(void)
{
ParseIdentifier();
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseIntConst implements: */
/* */
/* <IntConst> :== <Digit> { <Digit> } */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseIntConst(void)
{
Accept(INTCONST);
}
/*--------------------------------------------------------------------------*/
/* */
/* ParseIdentifier implements: */
/* */
/* <Identifier> :== <Alpha> { <AlphaNum> } */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void ParseIdentifier(void)
{
Accept(IDENTIFIER);
}
/*--------------------------------------------------------------------------*/
/* */
/* LookupSymbol: Gets 's' field from item in lookahead */
/* (i.e.: CurrentToken.s), and then searches for */
/* a SYMBOL in Symbol Table which has this name. */
/* */
/* */
/* */
/* */
/* Inputs: None */
/* */
/* Outputs: None */
/* */
/* Returns: Stack Pointer variable, sptr */
/* */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE SYMBOL *LookupSymbol ( void )
{
SYMBOL *sptr;
if ( CurrentToken.code == IDENTIFIER )
{
sptr = Probe ( CurrentToken.s, NULL );
if ( sptr == NULL )
{
Error ( "Identifier not declared", CurrentToken.pos );
KillCodeGeneration();
}
}
else sptr = NULL;
return sptr;
}
/*--------------------------------------------------------------------------*/
/* */
/* MakeSymbolTableEntry: Creates symbol table entry for either a */
/* program, variable or procedure */
/* */
/* */
/* */
/* */
/* */
/* Inputs: symtype */
/* */
/* Outputs: None */
/* */
/* Returns: None */
/* */
/* */
/*--------------------------------------------------------------------------*/
PRIVATE void MakeSymbolTableEntry ( int symtype )
{
SYMBOL *oldsptr, *newsptr;
char *cptr;
int hashindex;
static int VarLctn = 0;
if ( CurrentToken.code == IDENTIFIER )
{
if ( NULL == ( oldsptr = Probe ( CurrentToken.s, &hashindex ))
|| oldsptr -> scope < scope )
{
if ( oldsptr == NULL )
cptr = CurrentToken.s;
else
cptr = oldsptr -> s;
if ( NULL == ( newsptr = EnterSymbol ( cptr, hashindex )))
{
Error("Fatal error in EnterSymbol", CurrentToken.pos );
printf("Fatal error in EnterSymbol. ");
printf("Compiler must exit immediately\n");
exit(EXIT_FAILURE);
}
else
{
if ( oldsptr == NULL )
PreserveString();
newsptr -> scope = scope;
newsptr -> type = symtype;
if ( symtype == STYPE_VARIABLE )
{
newsptr -> address = VarLctn;
VarLctn++;
}
else
newsptr -> address = -1;
}
}
else
{
Error("Error! Variable already declared", CurrentToken.pos );
KillCodeGeneration();
}
}
}
|
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
pthread_key_t var;
void destructor(void * p)
{
free(p);
pthread_setspecific(var, NULL);
}
void * Hilo1(void * id)
{
char * valor = (char *) pthread_getspecific(var);
if(valor == NULL)
{
valor = (char *)malloc(10*sizeof(char));
}
sprintf(valor, "HOLA");
pthread_setspecific(var, (void*)valor);
printf("En el hilo 1 var = %s\n", (char*)pthread_getspecific(var));
return NULL;
}
void * Hilo2(void * id)
{
int * valor;
if(pthread_getspecific(var) == NULL)
{
valor = (int *)malloc(sizeof(int));
}
*valor = 100;
pthread_setspecific(var, (void*)valor);
printf("En el hilo 2 var = %d\n", *((int*)pthread_getspecific(var)));
return NULL;
}
int main(int argc, char ** argv)
{
pthread_t tid1, tid2;
pthread_key_create(&var, destructor);
pthread_create(&tid1, NULL, Hilo1, NULL);
pthread_create(&tid2, NULL, Hilo2, NULL);
pthread_join(tid1, NULL);
pthread_join(tid2, NULL);
return 0;
}
|
#include "OPF.h"
#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE
void c_opf_classify(int *argc, char **argv)
{
EM_ASM(
FS.syncfs(true, function (err) {
// Error
});
);
errorOccurred = 0;
opf_PrecomputedDistance = 0;
if ((*argc != 4) && (*argc != 3))
{
fprintf(stderr, "\nusage opf_classify <P1> <P2>");
fprintf(stderr, "\nP1: test set in the OPF file format");
fprintf(stderr, "\nP2: OPF model file");
fprintf(stderr, "\nP3: precomputed distance file (leave it in blank if you are not using this resource\n");
return;
}
int n, i, p;
float time;
char fileName[256];
FILE *f = NULL;
timer tic, toc;
if (*argc == 4)
opf_PrecomputedDistance = 1;
fprintf(stdout, "\nReading data files ...");
//sprintf(fileName, "%s.cla", argv[1]);
Subgraph *gTest = ReadSubgraph(argv[1]), *gTrain = opf_ReadModelFile(argv[2]); if(errorOccurred) return;
fprintf(stdout, " OK");
if (opf_PrecomputedDistance){
opf_DistanceValue = opf_ReadDistances(argv[3], &n); if(errorOccurred) return;
int maxPosition = 0;
for (p = 0; p < gTest->nnodes; p++)
{
if(gTest->node[p].position > maxPosition)
maxPosition = gTest->node[p].position;
}
for (p = 0; p < gTrain->nnodes; p++)
{
if(gTrain->node[p].position > maxPosition)
maxPosition = gTrain->node[p].position;
}
if(maxPosition >= n){
errorOccurred = 1;
fprintf(stderr, "\nError! Some positions have no pre-calculated distance, the matrix size must be equal to or less than the maximum position of the nodes");
return;
}
}
fprintf(stdout, "\nClassifying test set ...");
//sprintf(fileName, "%s.pre", argv[1]);
gettimeofday(&tic, NULL);
opf_OPFClassifying(gTrain, gTest);
gettimeofday(&toc, NULL);
fprintf(stdout, " OK");
fprintf(stdout, "\nWriting output file ...");
sprintf(fileName, "%s.out", argv[1]);
opf_WriteOutputFile(gTest, fileName);
fprintf(stdout, " OK");
fprintf(stdout, "\nDeallocating memory ...");
DestroySubgraph(&gTrain);
DestroySubgraph(&gTest);
if (opf_PrecomputedDistance)
{
for (i = 0; i < n; i++)
free(opf_DistanceValue[i]);
free(opf_DistanceValue);
}
fprintf(stdout, " OK\n");
time = ((toc.tv_sec - tic.tv_sec) * 1000.0 + (toc.tv_usec - tic.tv_usec) * 0.001) / 1000.0;
fprintf(stdout, "\nTesting time: %f seconds\n", time);
sprintf(fileName, "%s.tim", argv[1]);
f = fopen(fileName, "a");
fprintf(f, "%f\n", time);
fclose(f);
EM_ASM(
FS.syncfs(function (err) {
// Error
});
);
}
|
#ifndef lint
static char *sccsid = "@(#)siglist.c 1.3 (ULTRIX) 1/29/87";
#endif lint
/************************************************************************
* *
* Copyright (c) 1985 by *
* Digital Equipment Corporation, Maynard, MA *
* All rights reserved. *
* *
* This software is furnished under a license and may be used and *
* copied only in accordance with the terms of such license and *
* with the inclusion of the above copyright notice. This *
* software or any other copies thereof may not be provided or *
* otherwise made available to any other person. No title to and *
* ownership of the software is hereby transferred. *
* *
* This software is derived from software received from the *
* University of California, Berkeley, and from Bell *
* Laboratories. Use, duplication, or disclosure is subject to *
* restrictions under license agreements with University of *
* California and with AT&T. *
* *
* The information in this software is subject to change without *
* notice and should not be construed as a commitment by Digital *
* Equipment Corporation. *
* *
* Digital assumes no responsibility for the use or reliability *
* of its software on equipment which is not supplied by Digital. *
* *
************************************************************************/
/************************************************************************
* Modification History
*
* David L Ballenger, 28-Jun-1985
* 001 Add descriptions for SIGUSR1 and SIGUSR2 from System V.
*
* Based on: siglist.c 4.2 (Berkeley) 2/10/83
*
************************************************************************/
#include <signal.h>
char *sys_siglist[NSIG] = {
"Signal 0",
"Hangup", /* SIGHUP */
"Interrupt", /* SIGINT */
"Quit", /* SIGQUIT */
"Illegal instruction", /* SIGILL */
"Trace/BPT trap", /* SIGTRAP */
"IOT trap", /* SIGIOT */
"EMT trap", /* SIGEMT */
"Floating point exception", /* SIGFPE */
"Killed", /* SIGKILL */
"Bus error", /* SIGBUS */
"Segmentation fault", /* SIGSEGV */
"Bad system call", /* SIGSYS */
"Broken pipe", /* SIGPIPE */
"Alarm clock", /* SIGALRM */
"Terminated", /* SIGTERM */
"Urgent I/O condition", /* SIGURG */
"Stopped (signal)", /* SIGSTOP */
"Stopped", /* SIGTSTP */
"Continued", /* SIGCONT */
"Child exited", /* SIGCHLD */
"Stopped (tty input)", /* SIGTTIN */
"Stopped (tty output)", /* SIGTTOU */
"I/O possible", /* SIGIO */
"Cputime limit exceeded", /* SIGXCPU */
"Filesize limit exceeded", /* SIGXFSZ */
"Virtual timer expired", /* SIGVTALRM */
"Profiling timer expired", /* SIGPROF */
"Window size changes", /* SIGWINCH */
"Signal 29",
"User signal 1", /* SIGUSR1 */
"User signal 2" /* SIGUSR2 */
};
|
/*
* File: invo_bzl.h
* Author: James Xu
*
* Created on 2016.12.17, PM 2:16
*/
#ifndef INVO_BZL_H
#define INVO_BZL_H
#include "commo_header.h"
#include "conve.h"
#include "clas_save.h"
#ifdef __cplusplus
extern "C" {
#endif
// int compbzl_create(char *data_directory);
// int compbzl_destroy();
//
int list_metho_bzl(prod_data *sresp, char *osdb, char *metho);
int list_class_bzl(prod_data *sresp, char *osdb, char *clasn, uint32 etype);
int list_clasd_bzl(char *clas_decl, char *osdb, char *clasn);
// int comp_advance_txt(char *line_txt);
int comp_metho_bzl(char *clang_txt, char *osdb, char *meth_txt);
int robk_metho_bzl(char *osdb, char *meth_txt);
int comp_class_bzl(char *clang_txt, char *osdb, char *clas_decl);
int robk_class_bzl(char *osdb, char *clas_decl);
int comp_imeth_bzl(char *clang_txt, char *osdb, char *meth_txt);
int robk_imeth_bzl(char *osdb, char *clasn, char *metnm, char *parat, char *iclas);
//
int repla_metho_bzl(char *clang_txt, char *osdb, char *meth_txt);
int repla_class_bzl(char *clang_txt, char *osdb, char *clas_decl);
//
int load_metho_bzl(char *clang_txt, char *osdb, char *meth_txt);
int load_class_bzl(char *clang_txt, char *osdb, char *clasn);
//
int dele_metho_bzl(char *osdb, char *methd);
int dele_class_bzl(char *osdb, char *clasn);
//
int class_integri_bzl(char *osdb, char *clasn);
int parse_cdata_bzl(char clas_data[CDATNO_NUMB][PARAM_LENGTH], char *osdb, char *clasn);
//
#define build_handle_bzl(handn, mepan, meth_txt) conve_handle_name(handn, mepan, meth_txt)
#define build_sobje_bzl(sobjn, clasn) build_sobje_txt(sobjn, clasn)
//
int creat_imeth_bzl(char *advan_txt, char *osdb, char *clasn, char *metnm, char *parat, char *iclas);
int drop_imeth_bzl(char *osdb, char *clasn, char *metnm, char *parat, char *iclas);
//
int build_imeth_bzl(char *crea_clas, char *inhe_line, char *iclas[METH_NUMB], char *imeth[METH_NUMB], char *parat[PARAM_NUMB], char *clas_decl);
#ifdef __cplusplus
}
#endif
#endif /* INVO_BZL_H */
|
#include<stdio.h>
void printArray(int a[],int size){
for (int i = 0; i < size; i++)
{
printf("%d ",a[i]);
}
}
int partision(int A[], int low,int high){
int pivot = A[low];
int i = low+1;
int j = high;
int temp;
do
{
while (A[i]<=pivot)
{
i++;
}
while(A[j]>pivot){
j--;
}
if(i<j){
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
} while (i<j);
temp=A[j];
A[j]=A[low];
A[low]=temp;
return j;
}
void quickSort(int A[],int low,int high){
int partisionIndex;
if(low<high){
partisionIndex = partision(A,low,high);
quickSort(A,low,partisionIndex-1);
quickSort(A,partisionIndex+1,high);
}
}
int main()
{
int *A,sizeOfArray;
printf("Enter the Size of the Array : \n");
scanf("%d",&sizeOfArray);
printf("Enter The Array : \n");
for (int i = 0; i < sizeOfArray; i++)
{
scanf("%d",&A[i]);
}
printf("The Original Array is : \n");
printArray(A,sizeOfArray);
quickSort(A,0,sizeOfArray-1);
printf("\nThe Sorted Array is : \n");
printArray(A,sizeOfArray);
return 0;
}
|
#include "geom.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
/* **************************************** */
/* returns the signed area of triangle abc. The area is positive if c
is to the left of ab, and negative if c is to the right of ab
*/
int signed_area2D(point2D a, point2D b, point2D c) {
return ((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x));
}
/* **************************************** */
/* return 1 if p,q,r collinear, and 0 otherwise */
int collinear(point2D p, point2D q, point2D r) {
return (signed_area2D(p, q, r) == 0);
}
/* **************************************** */
/* return 1 if c is strictly left of ab; 0 otherwise */
int left (point2D a, point2D b, point2D c) {
return (signed_area2D(a, b, c) > 0);
}
/* **************************************** */
/* return 1 if same point*/
int samePoint(point2D a, point2D b){
return ((a.x == b.x) && (a.y == b.y));
}
|
#ifndef ZNPCSPAWNER_H
#define ZNPCSPAWNER_H
#endif
|
/*
* BeanSim : Nand Flash Simulator by File Operations
* Authors: Bean.Li<lishizelibin@163.com>
*
* This file is part of BeanSim.
*
* BeanSim is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BeanSim is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BeanSim. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __COMMON_H__
#define __COMMON_H__
#define BEAN_DEBUG
#define PLATFORM_X86
//#define PLATFORM_ARM
#ifdef PLATFORM_X86
#include <stdio.h> // for printf
#include <stdlib.h>
#include <assert.h> // for assert
#include <stdbool.h>
#include <string.h>
#include <dirent.h>
//#include <io.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#elif defined(PLATFORM_ARM)
// ToDo
#else
// ToDO
#endif // PLATFORM
#ifndef TRUE
#define TRUE true
#endif
#ifndef FALSE
#define FALSE false
#endif
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define HASH_SIZE(n) ((size_t)1 << (n))
#define HASH_MASK(n) (HASH_SIZE(n) - 1)
#define roundup(x,n) (((x)+((n)-1))&(~((n)-1))) // power 2
enum LOG_LEVEL {
LOG_ALL,
LOG_WARN,
LOG_ERR
};
#ifdef BEAN_DEBUG
static enum LOG_LEVEL log_level_stat = LOG_ALL;
#define LOG(level, fmt, ...) \
do { \
if ((level) >= log_level_stat) { \
switch (level) { \
case LOG_WARN: \
printf("[WARN at %s %d]: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
break; \
case LOG_ERR: \
printf("[ERROR at %s %d]: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \
break; \
} \
} \
} while(0)
#define ASSERT(expr) \
do { \
if (!(expr)) { \
LOG(LOG_ERR, "Bean assert fail"); \
assert(0); \
} \
} while(0)
#else
#define LOG(level, fmt, ...)
#define ASSERT(expr)
#endif
static inline unsigned short calc_crc16(unsigned short crc, unsigned char data) {
unsigned short rc;
static const unsigned short crc16_table[] = {
0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,
0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,
0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,
0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,
0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,
0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,
0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,
0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,
0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,
0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,
0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,
0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,
0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,
0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,
0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,
0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,
0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,
0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,
0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,
0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,
0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,
0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,
0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,
0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,
0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,
0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,
0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,
0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,
0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,
0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0,
};
rc = (crc << 8) ^ crc16_table[(int)(((crc >> 8) ^ data) & 0xff)];
return rc;
}
static inline int fls32(unsigned int x)
{
int r = 32;
if (!x)
return 0;
if (!(x & 0xffff0000u)) {
x <<= 16;
r -= 16;
}
if (!(x & 0xff000000u)) {
x <<= 8;
r -= 8;
}
if (!(x & 0xf0000000u)) {
x <<= 4;
r -= 4;
}
if (!(x & 0xc0000000u)) {
x <<= 2;
r -= 2;
}
if (!(x & 0x80000000u)) {
x <<= 1;
r -= 1;
}
return r;
}
static inline int fls64(unsigned long long x)
{
unsigned int _x = x >> 32;
if (_x)
return fls32(_x) + 32;
return fls32(x);
}
static inline bool is_power_of_2(unsigned long n)
{
return (n != 0 && ((n & (n - 1)) == 0));
}
static inline unsigned long roundup_power2(unsigned long n)
{
if (sizeof(n) == 4)
return 1UL << fls32(n - 1);
return 1UL << fls64(n - 1);
}
static inline unsigned long roundown_power2(unsigned long n)
{
if (sizeof(n) == 4)
return 1UL << (fls32(n) - 1);
return 1UL << (fls64(n) - 1);
}
static inline int calc_msb_index(unsigned int n)
{
unsigned int _n = 1;
if (n == 0)
return -1;
if ((n >> 16) == 0) {
_n += 16;
n <<= 16;
}
if ((n >> 24) == 0) {
_n += 8;
n <<= 8;
}
if ((n >> 28) == 0) {
_n += 4;
n <<= 4;
}
if ((n >> 30) == 0) {
_n += 2;
n <<= 2;
}
_n -= (n >> 31);
return 31 - _n;
}
static inline double power(double n, int p)
{
int i;
double pow = 1;
for (i = 0; i < p; i++)
pow *= n;
return pow;
}
static inline void *mem_alloc(unsigned int size)
{
void *buf;
if (!size)
return NULL;
buf = malloc(size);
if (!buf)
ASSERT(0);
memset(buf, 0, size);
return buf;
}
static inline void mem_free(void *mem)
{
if (mem != NULL)
free(mem);
}
#endif // __COMMON_H__
|
/*
** EPITECH PROJECT, 2017
** key_pressed
** File description:
** Desc
*/
#include "fight.h"
void key_down(t_fight *fight, t_select *select)
{
if (sfKeyboard_isKeyPressed(sfKeyDown) == sfTrue
&& select[0].i == 0)
select_bottom(fight, select);
else if (sfKeyboard_isKeyPressed(sfKeyDown) == sfTrue
&& select[0].i != 0)
select_specific_bottom(fight, select);
}
void key_up(t_fight *fight, t_select *select)
{
if (sfKeyboard_isKeyPressed(sfKeyUp) == sfTrue
&& select[0].i == 0)
select_upper(fight, select);
else if (sfKeyboard_isKeyPressed(sfKeyUp) == sfTrue
&& select[0].i != 0)
select_specific_upper(fight, select);
}
void key_ok(t_fight *fight, t_select *select, t_window *window, wait_t *wait)
{
if (sfKeyboard_isKeyPressed(sfKeyReturn) == sfTrue
&& select[0].i != 0 && select[0].select == 1) {
check_attack(fight, select, window, wait);
}
if (sfKeyboard_isKeyPressed(sfKeyReturn) == sfTrue
&& select[0].i != 0 && select[0].select == 2) {
check_defence(fight, select, window, wait);
}
if (sfKeyboard_isKeyPressed(sfKeyReturn) == sfTrue
&& select[0].i != 0 && select[0].select == 3) {
check_help(fight, select, wait);
sfSprite_setPosition(fight[3].sprite, fight[3].pos_bonus);
sfSprite_setPosition(fight[4].sprite, fight[4].pos_bonus);
}
}
void select_right_left(t_select *select)
{
if (select[0].select == 1)
sfSprite_setPosition(select[0].sprite,
select[0].attack_bot);
if (select[0].select == 2)
sfSprite_setPosition(select[0].sprite,
select[0].def_bot);
if (select[0].select == 3)
sfSprite_setPosition(select[0].sprite,
select[0].bonus_bot);
}
void key_right_left(t_fight *fight, t_select *select, sfEvent event)
{
if (event.type == sfEvtKeyReleased
&& (event.key.code == sfKeyReturn
|| event.key.code == sfKeyRight)
&& select[0].i == 0) {
select[0].i = 1;
select[0].visible = 1;
}
if (event.type == sfEvtKeyReleased
&& (event.key.code == sfKeyBack
|| event.key.code == sfKeyLeft)
&& select[0].i != 0) {
select[0].i = 0;
select[0].visible = 0;
select[0].specifics = 1;
sfSprite_setPosition(fight[2].sprite, fight[2].pos_def);
select_right_left(select);
}
}
|
/*
* rc.h
*
* Created on: 05.04.2016
* Author: Arndt
*/
#ifndef RC_H_
#define RC_H_
#include <Arduino.h>
#include <FreeRTOS.h>
#include <FreeRTOSConfig.h>
#include <task.h>
#include <RCSwitch.h>
#include <FiFo.h>
#include "defines.h"
enum rc_type {
A=0,
B=1,
C=2,
D=3
};
struct RcQueueTxCommand {
int protocol; // timing characteristics 1..5 (default 1)
rc_type type;
char family;
char group;
char device;
bool state;
};
struct RcQueueRxEntry {
unsigned int protocol;
unsigned long value;
};
extern FiFo RcSendQueue;
extern FiFo RcReceiveQueue;
extern FiFo RcMsgBuffer;
extern RCSwitch RcSwitch;
extern bool rc_rxen;
extern bool rc_txen;
extern int rc_txrepeat;
extern int rc_protocol;
void remoteControlSetup();
void remoteControlLoop();
#endif /* RC_H_ */
|
/* Copyright (c) 2013 The F9 Microkernel Project. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <os/platform/debug_device.h>
#include <errno.h>
#include <os/types.h>
#ifdef CONFIG_DEBUG_DEV_UART
//#include <os/debug_uart.h>
#endif
#ifdef CONFIG_DEBUG_DEV_RAM
#include <os/debug_ram.h>
#endif
#ifdef DEBUG_DEVICE_EXIST
static dbg_dev_t dbg_dev[DBG_DEV_MAX];
static dbg_dev_t *cur_dev = &dbg_dev[0];
static uint8_t default_getchar(void)
{
return (EOF);
}
static void default_putchar(uint8_t chr)
{
chr = 0;
}
static void default_start_panic(void)
{
}
/*
* Receive a character from debug port
*/
uint8_t dbg_getchar(void)
{
return ((*cur_dev->getchar)());
}
/*
* Send a character to debug port
*/
void dbg_putchar(uint8_t chr)
{
(*cur_dev->putchar)(chr);
}
/*
* Do the preparing before entering panic. Previous characters in
* debug queue must be flushed out first.
*/
void dbg_start_panic(void)
{
if (!cur_dev || !cur_dev->start_panic)
return;
(*cur_dev->start_panic)();
}
/*
* Initialization procedure for debug IO port
*/
static void dbg_device_init(void)
{
int i;
for (i = 0; i < (DBG_DEV_MAX - 1); i++) {
dbg_dev_t *pdev = &dbg_dev[i];
pdev->dev_id = DBG_DEV_MAX;
pdev->getchar = default_getchar;
pdev->putchar = default_putchar;
pdev->start_panic = default_start_panic;
}
#ifdef CONFIG_DEBUG_DEV_UART
dbg_uart_init();
#endif
#ifdef CONFIG_DEBUG_DEV_RAM
dbg_ram_init();
#endif
}
/*
* Register device IO port objects
*/
int32_t dbg_register_device(dbg_dev_t *device)
{
dbg_dev_t *pdev;
if (!device)
return -EINVAL;
if (device->dev_id >= DBG_DEV_MAX)
return -EINVAL;
pdev = &dbg_dev[device->dev_id];
pdev->dev_id = device->dev_id;
pdev->getchar = device->getchar;
pdev->putchar = device->putchar;
pdev->start_panic = device->start_panic;
return 0;
}
int32_t dbg_change_device(dbg_dev_id_t dev_id)
{
if (dev_id >= DBG_DEV_MAX)
return -EINVAL;
if (dbg_dev[dev_id].dev_id == DBG_DEV_MAX)
return -ENXIO;
cur_dev = &dbg_dev[dev_id];
return 0;
}
#else /* DEBUG_DEVICE_EXIST */
uint8_t dbg_getchar(void)
{
return (EOF);
}
void dbg_putchar(uint8_t chr)
{
chr = 0;
}
void dbg_start_panic(void)
{
}
#endif /* DEBUG_DEVICE_EXIST */
#ifdef CONFIG_DEBUG
extern dbg_layer_t dbg_layer;
void dbg_device_init_hook(void)
{
#ifdef DEBUG_DEVICE_EXIST
dbg_device_init();
#endif
dbg_layer = DL_KDB;
}
INIT_HOOK(dbg_device_init_hook, INIT_LEVEL_PLATFORM);
#endif
#ifdef CONFIG_STDIO_USE_DBGPORT
uint8_t __l4_getchar(void)
__attribute__((weak, alias("dbg_getchar")));
void __l4_putchar(uint8_t chr)
__attribute__((weak, alias("dbg_putchar")));
#endif
|
/*
FuseCompress
Copyright (C) 2005 Milan Svoboda <milan.svoboda@centrum.cz>
(C) 2011 Ulrich Hecht <uli@suse.de>
*/
#include "structs.h"
extern int min_filesize_background;
extern int root_fs;
extern int read_only;
extern int cache_decompressed_data;
extern int decomp_cache_size;
extern int max_decomp_cache_size;
extern size_t dont_compress_beyond;
extern int dedup_enabled;
extern int dedup_redup;
#define DC_PAGE_SIZE (4096)
extern pthread_t pt_comp;
extern pthread_mutexattr_t locktype;
extern compressor_t *compressor_default;
extern compressor_t *compressors[5];
extern char *incompressible[];
extern char **user_incompressible;
extern char **user_exclude_paths;
extern char *mmapped_dirs[];
extern database_t database;
extern database_t comp_database;
void *thread_compress(void *arg);
#define PCFS_PREFIX "._fC"
#define TEMP PCFS_PREFIX "tmp" /* Template is: ._.tmpXXXXXX */
#define FUSE ".fuse_hidden" /* Temporary FUSE file */
#define DEDUP_DB_FILE PCFS_PREFIX "dedup_db"
#define DEDUP_ATTR PCFS_PREFIX "at_"
extern char compresslevel[];
#define COMPRESSLEVEL_BACKGROUND (compresslevel) /* See above, this is for background compress */
// Gcc optimizations
//
#if __GNUC__ >= 3
# define likely(x) __builtin_expect (!!(x), 1)
# define unlikely(x) __builtin_expect (!!(x), 0)
#else
# define likely(x) (x)
# define unlikely(x) (x)
#endif
|
#include <keyboard.h>
#include <print.h>
#include <8259A.h>
#include <int.h>
#include <x86.h>
extern unsigned char scancode_types[];
extern char scancode_ascii[];
extern char scancode_shift_ascii[];
void key_putc(char);
static struct key_desc keys;
void keyboard_interrupt(struct regs *reg)
{
/*
* We must read this scan code from the buffer
* otherwise the keyboard interrupt will be closed.
*/
u8 scan_code = inb(0x60);
u8 press = 1;
int type;
char c;
/* Just skip prefix code: 0xE0 */
if (scan_code == KEY_E0)
return;
/* scan code of pause key: 0xe1 0x1d 0x45 0xe1 0x4d 0xc5 */
if (scan_code == KEY_E1 || keys.pause) {
keys.pause = 1;
if (scan_code == 0xc5)
keys.pause = 0;
return;
}
if (scan_code & KEY_RELEASE_BIT) {
scan_code &= 0x7f;
press = 0;
}
/* get scancode types */
type = scancode_types[scan_code];
/* handle none code */
if (press && type == KEY_NONE) {
printk("None scan code: %x\n", scan_code);
return;
}
/* handle prefix code */
if (scancode_types[scan_code] == KEY_PREFIX) {
switch (scan_code) {
case KEY_ESC:
keys.esc = press;
break;
case KEY_CAPSLOCK:
if (press)
keys.capslock = !keys.capslock;
break;
case KEY_LSHIFT:
case KEY_RSHIFT:
keys.shift = press;
break;
case KEY_START:
keys.start = press;
break;
case KEY_ALT:
keys.alt = press;
break;
case KEY_CTRL:
keys.ctrl = press;
break;
}
return;
}
/* handle acsii scan code */
if (press && type == KEY_ASCII) {
if (keys.capslock || keys.shift)
c = scancode_shift_ascii[scan_code];
else
c = scancode_ascii[scan_code];
/* EOF */
if ((c == 'd' || c == 'D') && keys.ctrl)
c = '\0';
key_putc(c);
}
}
void keyboard_init(void)
{
/* open keyboard interrupt */
unmask_8259A(IRQ_KEYBOARD);
}
|
#include <stdio.h>
#include <stdlib.h>
#include "linkedlist.h"
void addFirst(int d){
Node * newNode =
}
void printList(){
if (head==NULL)
printf("Emptylist\n");
else
}
|
#ifndef FUNCIONES_H_INCLUDED
#define FUNCIONES_H_INCLUDED
#endif // FUNCIONES_H_INCLUDED
float numeroA();
/** \brief numeroA obtiene un numero para 1er operando ingresado por el usuario.
*
* \param num guarda el numero ingresado.
* \return num devuelve el valor ingresado.
*
*/
float numeroB();
/** \brief numeroA obtiene un numero para 1er operando ingresado por el usuario.
*
* \param num guarda el numero ingresado.
* \return num devuelve el valor ingresado.
*
*/
float suma(float a, float b);
/** \brief suma los dos numeros que obtiene de numeroA y numeroB.
*
* \param suma, obtiene el valor de la suma de x e y.
* \param a tiene el valor de numeroA.
* \param b tiene el valor de numeroB.
* \return devuelve el resultado.
*
*/
float resta(float a, float b);
/** \brief resta los dos numeros que obtiene de numeroA y numeroB.
*
* \param resta, obtiene el valor de la resta de x e y.
* \param a tiene el valor de numeroA.
* \param b tiene el valor de numeroB.
* \return devuelve el resultado.
*
*/
float division(float a, float b);
/** \brief divide los dos numeros que obtiene de numeroA y numeroB.
*
* \param division, obtiene el valor de la division de x e y.
* \param a tiene el valor de numeroA.
* \param b tiene el valor de numeroB.
* \return devuelve el resultado.
*
*/
float multiplicacion(float a, float b);
/** \brief multiplica los dos numeros que obtiene de numeroA y numeroB.
*
* \param multiplicacion, obtiene el valor de la multiplicacion de x e y.
* \param a tiene el valor de numeroA.
* \param b tiene el valor de numeroB.
* \return devuelve el resultado.
*
*/
float factorial(float a);
/** \brief factorialA, hace la factorizacion de numeroA.
*
* \param fact 1 valor que se multiplica con i.
* \param i obtiene el valor de numeroA.
* \return fact devuelve el factoreo.
*
*/
|
/*
* 1wire_bus.h
*
* Created on: 2020年11月30日
* Author: tom
*/
#ifndef ONE_WIRE_BUS_H_
#define ONE_WIRE_BUS_H_
#include "gpio.h"
#define ONE_WIRE_SEARCH_ROM 0xF0
#define ONE_WIRE_READ_ROM 0x33
#define ONE_WIRE_MATCH_ROM 0x55
#define ONE_WIRE_SKIP_ROM 0xCC
#define ONE_WIRE_ALARM_SEARCH 0xEC
#define one_wire_bus P15//P35
unsigned char one_wire_bus_present();
void one_wire_bus_write(unsigned char value);
unsigned char one_wire_bus_read();
/*
* search the device rom on the bus
*
* alarm_search !=0 perform alarm searching.
* *result will save in the search result , which point to the memory has alloced more than n_rom x 8 byte .
* n_rom limit the number of device of searching.
*
* return the number of devices which has been found.
*/
unsigned char one_wire_bus_search_rom(unsigned char alarm_search ,unsigned char *result,unsigned char n_rom);
void one_wire_bus_read_rom(unsigned char *result);
void one_wire_bus_match_rom(unsigned char *rom);
#endif /* 1WIRE_BUS_H_ */
|
void fit_mjj_Full_PFNo3Dijet2017bgCSVv2le1b800()
{
//=========Macro generated from canvas: c/c
//========= (Thu Sep 20 01:51:07 2018) by ROOT version6.02/05
TCanvas *c = new TCanvas("c", "c",0,0,600,700);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
c->SetHighLightColor(2);
c->Range(0,0,1,1);
c->SetFillColor(0);
c->SetBorderMode(0);
c->SetBorderSize(2);
c->SetTopMargin(0.04761905);
c->SetBottomMargin(0.05);
c->SetFrameBorderMode(0);
// ------------>Primitives in pad: c_1
TPad *c_1 = new TPad("c_1", "c_1",0.01,0.37,0.99,0.98);
c_1->Draw();
c_1->cd();
c_1->Range(2.91482,-7.69897,3.947382,1.774714);
c_1->SetFillColor(0);
c_1->SetBorderMode(0);
c_1->SetBorderSize(2);
c_1->SetLogx();
c_1->SetLogy();
c_1->SetLeftMargin(0.175);
c_1->SetRightMargin(0.05);
c_1->SetTopMargin(0.05);
c_1->SetBottomMargin(0);
c_1->SetFrameFillStyle(0);
c_1->SetFrameBorderMode(0);
c_1->SetFrameFillStyle(0);
c_1->SetFrameBorderMode(0);
Double_t xAxis1[45] = {1246, 1313, 1383, 1455, 1530, 1607, 1687, 1770, 1856, 1945, 2037, 2132, 2231, 2332, 2438, 2546, 2659, 2775, 2895, 3019, 3147, 3279, 3416, 3558, 3704, 3854, 4010, 4171, 4337, 4509, 4686, 4869, 5058, 5253, 5455, 5663, 5877, 6099, 6328, 6564, 6808, 7060, 7320, 7589, 7866};
TH1D *data_obs_density1 = new TH1D("data_obs_density1","",44, xAxis1);
data_obs_density1->SetMinimum(2e-08);
data_obs_density1->SetMaximum(20);
data_obs_density1->SetEntries(10044);
data_obs_density1->SetLineColor(0);
data_obs_density1->SetLineWidth(0);
data_obs_density1->SetMarkerColor(0);
data_obs_density1->GetXaxis()->SetRange(1,44);
data_obs_density1->GetXaxis()->SetLabelFont(42);
data_obs_density1->GetXaxis()->SetLabelSize(0.035);
data_obs_density1->GetXaxis()->SetTitleSize(0.035);
data_obs_density1->GetXaxis()->SetTitleFont(42);
data_obs_density1->GetYaxis()->SetTitle("d#sigma/dm_{jj} [pb/TeV]");
data_obs_density1->GetYaxis()->SetLabelFont(42);
data_obs_density1->GetYaxis()->SetLabelOffset(1000);
data_obs_density1->GetYaxis()->SetLabelSize(0.05);
data_obs_density1->GetYaxis()->SetTitleSize(0.07);
data_obs_density1->GetYaxis()->SetTitleFont(42);
data_obs_density1->GetZaxis()->SetLabelFont(42);
data_obs_density1->GetZaxis()->SetLabelSize(0.035);
data_obs_density1->GetZaxis()->SetTitleSize(0.035);
data_obs_density1->GetZaxis()->SetTitleFont(42);
data_obs_density1->Draw("axis");
TF1 *PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1 = new TF1("*PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin",1246,7866,1);
//The original function : had originally been created by:
//TF1 *PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin = new TF1("PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin",,1246,7866,1);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetRange(1246,7866);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetName("PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin");
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetTitle("");
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(0,0.001111603);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(1,0.002284628);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(2,0.004033681);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(3,0.006251862);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(4,0.008661882);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(5,0.0108931);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(6,0.01259698);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(7,0.01354482);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(8,0.01367127);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(9,0.01306005);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(10,0.01189264);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(11,0.01038741);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(12,0.008749664);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(13,0.007141719);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(14,0.005672396);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(15,0.004400444);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(16,0.003345209);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(17,0.002499307);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(18,0.001840012);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(19,0.001337954);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(20,0.0009629226);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(21,0.0006872093);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(22,0.0004871592);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(23,0.0003435596);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(24,0.0002413707);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(25,0.0001691468);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(26,0.0001183684);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(27,8.28042e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(28,5.795953e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(29,4.062842e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(30,2.854383e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(31,2.011354e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(32,1.42249e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(33,1.010329e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(34,7.210679e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(35,5.173907e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(36,3.734239e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(37,2.712213e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(38,1.983202e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(39,1.460505e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(40,1.083656e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(41,8.103696e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(42,6.10968e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(43,4.645478e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(44,3.563235e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(45,2.757906e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(46,2.154508e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(47,1.699254e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(48,1.353356e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(49,1.0887e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(50,8.847927e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(51,7.266121e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(52,6.030867e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(53,5.060093e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(54,4.292616e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(55,3.682573e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(56,3.195408e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(57,2.804947e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(58,2.491285e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(59,2.23923e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(60,2.037163e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(61,1.876202e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(62,1.749583e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(63,1.652211e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(64,1.580326e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(65,1.531276e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(66,1.503354e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(67,1.495705e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(68,1.508288e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(69,1.541894e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(70,1.598216e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(71,1.679993e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(72,1.791233e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(73,1.937549e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(74,2.126642e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(75,2.368993e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(76,2.678861e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(77,3.075703e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(78,3.586245e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(79,4.247494e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(80,5.111186e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(81,6.2504e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(82,7.769549e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(83,9.819584e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(84,1.262149e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(85,1.6503e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(86,2.195674e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(87,2.973362e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(88,4.099479e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(89,5.756269e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(90,8.234174e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(91,1.200343e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(92,1.783783e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(93,2.703211e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(94,4.179025e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(95,6.593085e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(96,1.061913e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(97,1.746825e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(98,2.935971e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(99,5.0441e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(100,8.862192e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(101,1246);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetSavedPoint(102,7866);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetFillColor(19);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetFillStyle(0);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetLineColor(2);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetLineWidth(2);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetXaxis()->SetLabelFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetXaxis()->SetLabelSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetXaxis()->SetTitleSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetXaxis()->SetTitleFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetYaxis()->SetLabelFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetYaxis()->SetLabelSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetYaxis()->SetTitleSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->GetYaxis()->SetTitleFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetParameter(0,2.722925e-79);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetParError(0,0);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->SetParLimits(0,0,0);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin1->Draw("csame");
TLatex * tex = new TLatex(0.72,0.96,"41.8 fb^{-1} (13 TeV)");
tex->SetNDC();
tex->SetTextFont(42);
tex->SetTextSize(0.045);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0.22,0.89,"CMS");
tex->SetNDC();
tex->SetTextSize(0.065);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0.32,0.89,"Preliminary");
tex->SetNDC();
tex->SetTextFont(52);
tex->SetTextSize(0.045);
tex->SetLineWidth(2);
tex->Draw();
TLegend *leg = new TLegend(0.6,0.58,0.89,0.94,NULL,"brNDC");
leg->SetBorderSize(1);
leg->SetLineColor(0);
leg->SetLineStyle(1);
leg->SetLineWidth(0);
leg->SetFillColor(0);
leg->SetFillStyle(0);
TLegendEntry *entry=leg->AddEntry("Graph_from_data_obs_rebin","Data","pe");
entry->SetLineColor(1);
entry->SetLineStyle(1);
entry->SetLineWidth(1);
entry->SetMarkerColor(1);
entry->SetMarkerStyle(20);
entry->SetMarkerSize(0.9);
entry->SetTextFont(42);
entry=leg->AddEntry("PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin","Fit","l");
entry->SetLineColor(2);
entry->SetLineStyle(1);
entry->SetLineWidth(2);
entry->SetMarkerColor(1);
entry->SetMarkerStyle(21);
entry->SetMarkerSize(1);
entry->SetTextFont(42);
leg->Draw();
TPaveText *pt = new TPaveText(0.2,0.03,0.5,0.23,"brNDC");
pt->SetBorderSize(0);
pt->SetFillColor(0);
pt->SetFillStyle(0);
pt->SetTextAlign(11);
pt->SetTextFont(42);
pt->SetTextSize(0.045);
AText = pt->AddText("#chi^{2} / ndf = 467006.9 / 33 = 14151.7");
AText = pt->AddText("Wide PF-jets");
AText = pt->AddText("m_{jj} > 1.25 TeV");
AText = pt->AddText("|#eta| < 2.5, |#Delta#eta| < 1.3");
pt->Draw();
TF1 *PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2 = new TF1("*PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin",1246,7866,1);
//The original function : had originally been created by:
//TF1 *PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin = new TF1("PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin",,1246,7866,1);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetRange(1246,7866);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetName("PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin");
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetTitle("");
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(0,0.001111603);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(1,0.002284628);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(2,0.004033681);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(3,0.006251862);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(4,0.008661882);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(5,0.0108931);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(6,0.01259698);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(7,0.01354482);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(8,0.01367127);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(9,0.01306005);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(10,0.01189264);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(11,0.01038741);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(12,0.008749664);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(13,0.007141719);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(14,0.005672396);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(15,0.004400444);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(16,0.003345209);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(17,0.002499307);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(18,0.001840012);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(19,0.001337954);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(20,0.0009629226);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(21,0.0006872093);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(22,0.0004871592);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(23,0.0003435596);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(24,0.0002413707);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(25,0.0001691468);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(26,0.0001183684);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(27,8.28042e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(28,5.795953e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(29,4.062842e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(30,2.854383e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(31,2.011354e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(32,1.42249e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(33,1.010329e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(34,7.210679e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(35,5.173907e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(36,3.734239e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(37,2.712213e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(38,1.983202e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(39,1.460505e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(40,1.083656e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(41,8.103696e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(42,6.10968e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(43,4.645478e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(44,3.563235e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(45,2.757906e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(46,2.154508e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(47,1.699254e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(48,1.353356e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(49,1.0887e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(50,8.847927e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(51,7.266121e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(52,6.030867e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(53,5.060093e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(54,4.292616e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(55,3.682573e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(56,3.195408e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(57,2.804947e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(58,2.491285e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(59,2.23923e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(60,2.037163e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(61,1.876202e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(62,1.749583e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(63,1.652211e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(64,1.580326e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(65,1.531276e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(66,1.503354e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(67,1.495705e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(68,1.508288e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(69,1.541894e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(70,1.598216e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(71,1.679993e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(72,1.791233e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(73,1.937549e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(74,2.126642e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(75,2.368993e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(76,2.678861e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(77,3.075703e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(78,3.586245e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(79,4.247494e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(80,5.111186e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(81,6.2504e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(82,7.769549e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(83,9.819584e-08);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(84,1.262149e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(85,1.6503e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(86,2.195674e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(87,2.973362e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(88,4.099479e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(89,5.756269e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(90,8.234174e-07);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(91,1.200343e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(92,1.783783e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(93,2.703211e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(94,4.179025e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(95,6.593085e-06);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(96,1.061913e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(97,1.746825e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(98,2.935971e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(99,5.0441e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(100,8.862192e-05);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(101,1246);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetSavedPoint(102,7866);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetFillColor(19);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetFillStyle(0);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetLineColor(2);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetLineWidth(2);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetXaxis()->SetLabelFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetXaxis()->SetLabelSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetXaxis()->SetTitleSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetXaxis()->SetTitleFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetYaxis()->SetLabelFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetYaxis()->SetLabelSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetYaxis()->SetTitleSize(0.035);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->GetYaxis()->SetTitleFont(42);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetParameter(0,2.722925e-79);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetParError(0,0);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->SetParLimits(0,0,0);
PFNo3Dijet2017bgCSVv2le1b800_bkg_unbin2->Draw("csame");
Double_t g_data_clone_fx3001[44] = {
1279.5,
1348,
1419,
1492.5,
1568.5,
1647,
1728.5,
1813,
1900.5,
1991,
2084.5,
2181.5,
2281.5,
2385,
2492,
2602.5,
2717,
2835,
2957,
3083,
3213,
3347.5,
3487,
3631,
3779,
3932,
4090.5,
4254,
4423,
4597.5,
4777.5,
4963.5,
5155.5,
5354,
5559,
5770,
5988,
6213.5,
6446,
6686,
6934,
7190,
7454.5,
7727.5};
Double_t g_data_clone_fy3001[44] = {
0,
0,
0,
0.0004446571,
0.02931616,
0.0217488,
0.01611316,
0.01183682,
0.008838235,
0.006499376,
0.004794762,
0.003545261,
0.002604339,
0.001968493,
0.00142566,
0.001065123,
0.0007744184,
0.0005727671,
0.0004275351,
0.0002945574,
0.0002287226,
0.0001569867,
0.0001088348,
8.864783e-05,
6.698565e-05,
4.81536e-05,
3.165027e-05,
2.262639e-05,
1.488261e-05,
1.13535e-05,
8.366669e-06,
6.328954e-06,
2.576371e-06,
4.263584e-06,
1.610232e-06,
1.341502e-06,
1.077633e-06,
5.22346e-07,
6.082232e-07,
1.960938e-07,
0,
0,
0,
0};
Double_t g_data_clone_felx3001[44] = {
33.5,
35,
36,
37.5,
38.5,
40,
41.5,
43,
44.5,
46,
47.5,
49.5,
50.5,
53,
54,
56.5,
58,
60,
62,
64,
66,
68.5,
71,
73,
75,
78,
80.5,
83,
86,
88.5,
91.5,
94.5,
97.5,
101,
104,
107,
111,
114.5,
118,
122,
126,
130,
134.5,
138.5};
Double_t g_data_clone_fely3001[44] = {
0,
0,
0,
1.190834e-05,
9.543962e-05,
8.064788e-05,
6.815085e-05,
5.738361e-05,
4.874239e-05,
4.111121e-05,
3.474875e-05,
2.927001e-05,
2.483721e-05,
2.107788e-05,
1.777076e-05,
1.501645e-05,
1.263749e-05,
1.068549e-05,
9.081624e-06,
7.419167e-06,
6.437708e-06,
5.234938e-06,
4.281033e-06,
3.810172e-06,
3.267334e-06,
2.716076e-06,
2.166984e-06,
1.803896e-06,
1.436534e-06,
1.236323e-06,
1.043115e-06,
8.920629e-07,
5.577097e-07,
7.072944e-07,
4.251664e-07,
3.818054e-07,
3.350088e-07,
2.256247e-07,
2.412587e-07,
1.266599e-07,
0,
0,
0,
0};
Double_t g_data_clone_fehx3001[44] = {
33.5,
35,
36,
37.5,
38.5,
40,
41.5,
43,
44.5,
46,
47.5,
49.5,
50.5,
53,
54,
56.5,
58,
60,
62,
64,
66,
68.5,
71,
73,
75,
78,
80.5,
83,
86,
88.5,
91.5,
94.5,
97.5,
101,
104,
107,
111,
114.5,
118,
122,
126,
130,
134.5,
138.5};
Double_t g_data_clone_fehy3001[44] = {
6.573787e-07,
6.292053e-07,
6.117274e-07,
1.22316e-05,
9.575083e-05,
8.094749e-05,
6.84397e-05,
5.766247e-05,
4.901194e-05,
4.137208e-05,
3.500149e-05,
2.951266e-05,
2.507521e-05,
2.130479e-05,
1.799366e-05,
1.522966e-05,
1.284541e-05,
1.088672e-05,
9.276611e-06,
7.60843e-06,
6.621505e-06,
5.412482e-06,
4.45283e-06,
3.977562e-06,
3.430724e-06,
2.873769e-06,
2.32068e-06,
1.953778e-06,
1.582365e-06,
1.378878e-06,
1.182038e-06,
1.027619e-06,
6.938164e-07,
8.35626e-07,
5.555851e-07,
5.097607e-07,
4.598297e-07,
3.533711e-07,
3.632828e-07,
2.586389e-07,
1.747793e-07,
1.694014e-07,
1.637337e-07,
1.59005e-07};
TGraphAsymmErrors *grae = new TGraphAsymmErrors(44,g_data_clone_fx3001,g_data_clone_fy3001,g_data_clone_felx3001,g_data_clone_fehx3001,g_data_clone_fely3001,g_data_clone_fehy3001);
grae->SetName("g_data_clone");
grae->SetTitle("");
grae->SetMarkerStyle(20);
grae->SetMarkerSize(0);
TH1F *Graph_g_data_clone3001 = new TH1F("Graph_g_data_clone3001","",100,584,8528);
Graph_g_data_clone3001->SetMinimum(3.23531e-05);
Graph_g_data_clone3001->SetMaximum(0.0323531);
Graph_g_data_clone3001->SetDirectory(0);
Graph_g_data_clone3001->SetStats(0);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
Graph_g_data_clone3001->SetLineColor(ci);
Graph_g_data_clone3001->GetXaxis()->SetLabelFont(42);
Graph_g_data_clone3001->GetXaxis()->SetLabelSize(0.035);
Graph_g_data_clone3001->GetXaxis()->SetTitleSize(0.035);
Graph_g_data_clone3001->GetXaxis()->SetTitleFont(42);
Graph_g_data_clone3001->GetYaxis()->SetLabelFont(42);
Graph_g_data_clone3001->GetYaxis()->SetLabelSize(0.035);
Graph_g_data_clone3001->GetYaxis()->SetTitleSize(0.035);
Graph_g_data_clone3001->GetYaxis()->SetTitleFont(42);
Graph_g_data_clone3001->GetZaxis()->SetLabelFont(42);
Graph_g_data_clone3001->GetZaxis()->SetLabelSize(0.035);
Graph_g_data_clone3001->GetZaxis()->SetTitleSize(0.035);
Graph_g_data_clone3001->GetZaxis()->SetTitleFont(42);
grae->SetHistogram(Graph_g_data_clone3001);
grae->Draw("zp");
Double_t Graph_from_data_obs_rebin_fx3002[44] = {
1279.5,
1348,
1419,
1492.5,
1568.5,
1647,
1728.5,
1813,
1900.5,
1991,
2084.5,
2181.5,
2281.5,
2385,
2492,
2602.5,
2717,
2835,
2957,
3083,
3213,
3347.5,
3487,
3631,
3779,
3932,
4090.5,
4254,
4423,
4597.5,
4777.5,
4963.5,
5155.5,
5354,
5559,
5770,
5988,
6213.5,
6446,
6686,
6934,
7190,
7454.5,
7727.5};
Double_t Graph_from_data_obs_rebin_fy3002[44] = {
99999,
99999,
99999,
0.0004446571,
0.02931616,
0.0217488,
0.01611316,
0.01183682,
0.008838235,
0.006499376,
0.004794762,
0.003545261,
0.002604339,
0.001968493,
0.00142566,
0.001065123,
0.0007744184,
0.0005727671,
0.0004275351,
0.0002945574,
0.0002287226,
0.0001569867,
0.0001088348,
8.864783e-05,
6.698565e-05,
4.81536e-05,
3.165027e-05,
2.262639e-05,
1.488261e-05,
1.13535e-05,
8.366669e-06,
6.328954e-06,
2.576371e-06,
4.263584e-06,
1.610232e-06,
1.341502e-06,
1.077633e-06,
5.22346e-07,
6.082232e-07,
1.960938e-07,
99999,
99999,
99999,
99999};
Double_t Graph_from_data_obs_rebin_felx3002[44] = {
33.5,
35,
36,
37.5,
38.5,
40,
41.5,
43,
44.5,
46,
47.5,
49.5,
50.5,
53,
54,
56.5,
58,
60,
62,
64,
66,
68.5,
71,
73,
75,
78,
80.5,
83,
86,
88.5,
91.5,
94.5,
97.5,
101,
104,
107,
111,
114.5,
118,
122,
126,
130,
134.5,
138.5};
Double_t Graph_from_data_obs_rebin_fely3002[44] = {
0,
0,
0,
1.190834e-05,
9.543962e-05,
8.064788e-05,
6.815085e-05,
5.738361e-05,
4.874239e-05,
4.111121e-05,
3.474875e-05,
2.927001e-05,
2.483721e-05,
2.107788e-05,
1.777076e-05,
1.501645e-05,
1.263749e-05,
1.068549e-05,
9.081624e-06,
7.419167e-06,
6.437708e-06,
5.234938e-06,
4.281033e-06,
3.810172e-06,
3.267334e-06,
2.716076e-06,
2.166984e-06,
1.803896e-06,
1.436534e-06,
1.236323e-06,
1.043115e-06,
8.920629e-07,
5.577097e-07,
7.072944e-07,
4.251664e-07,
3.818054e-07,
3.350088e-07,
2.256247e-07,
2.412587e-07,
1.266599e-07,
0,
0,
0,
0};
Double_t Graph_from_data_obs_rebin_fehx3002[44] = {
33.5,
35,
36,
37.5,
38.5,
40,
41.5,
43,
44.5,
46,
47.5,
49.5,
50.5,
53,
54,
56.5,
58,
60,
62,
64,
66,
68.5,
71,
73,
75,
78,
80.5,
83,
86,
88.5,
91.5,
94.5,
97.5,
101,
104,
107,
111,
114.5,
118,
122,
126,
130,
134.5,
138.5};
Double_t Graph_from_data_obs_rebin_fehy3002[44] = {
6.573787e-07,
6.292053e-07,
6.117274e-07,
1.22316e-05,
9.575083e-05,
8.094749e-05,
6.84397e-05,
5.766247e-05,
4.901194e-05,
4.137208e-05,
3.500149e-05,
2.951266e-05,
2.507521e-05,
2.130479e-05,
1.799366e-05,
1.522966e-05,
1.284541e-05,
1.088672e-05,
9.276611e-06,
7.60843e-06,
6.621505e-06,
5.412482e-06,
4.45283e-06,
3.977562e-06,
3.430724e-06,
2.873769e-06,
2.32068e-06,
1.953778e-06,
1.582365e-06,
1.378878e-06,
1.182038e-06,
1.027619e-06,
6.938164e-07,
8.35626e-07,
5.555851e-07,
5.097607e-07,
4.598297e-07,
3.533711e-07,
3.632828e-07,
2.586389e-07,
1.747793e-07,
1.694014e-07,
1.637337e-07,
1.59005e-07};
grae = new TGraphAsymmErrors(44,Graph_from_data_obs_rebin_fx3002,Graph_from_data_obs_rebin_fy3002,Graph_from_data_obs_rebin_felx3002,Graph_from_data_obs_rebin_fehx3002,Graph_from_data_obs_rebin_fely3002,Graph_from_data_obs_rebin_fehy3002);
grae->SetName("Graph_from_data_obs_rebin");
grae->SetTitle("");
grae->SetMarkerStyle(20);
grae->SetMarkerSize(0.9);
TH1F *Graph_Graph_from_data_obs_rebin3002 = new TH1F("Graph_Graph_from_data_obs_rebin3002","",100,584,8528);
Graph_Graph_from_data_obs_rebin3002->SetMinimum(6.249052e-08);
Graph_Graph_from_data_obs_rebin3002->SetMaximum(109998.9);
Graph_Graph_from_data_obs_rebin3002->SetDirectory(0);
Graph_Graph_from_data_obs_rebin3002->SetStats(0);
ci = TColor::GetColor("#000099");
Graph_Graph_from_data_obs_rebin3002->SetLineColor(ci);
Graph_Graph_from_data_obs_rebin3002->GetXaxis()->SetLabelFont(42);
Graph_Graph_from_data_obs_rebin3002->GetXaxis()->SetLabelSize(0.035);
Graph_Graph_from_data_obs_rebin3002->GetXaxis()->SetTitleSize(0.035);
Graph_Graph_from_data_obs_rebin3002->GetXaxis()->SetTitleFont(42);
Graph_Graph_from_data_obs_rebin3002->GetYaxis()->SetLabelFont(42);
Graph_Graph_from_data_obs_rebin3002->GetYaxis()->SetLabelSize(0.035);
Graph_Graph_from_data_obs_rebin3002->GetYaxis()->SetTitleSize(0.035);
Graph_Graph_from_data_obs_rebin3002->GetYaxis()->SetTitleFont(42);
Graph_Graph_from_data_obs_rebin3002->GetZaxis()->SetLabelFont(42);
Graph_Graph_from_data_obs_rebin3002->GetZaxis()->SetLabelSize(0.035);
Graph_Graph_from_data_obs_rebin3002->GetZaxis()->SetTitleSize(0.035);
Graph_Graph_from_data_obs_rebin3002->GetZaxis()->SetTitleFont(42);
grae->SetHistogram(Graph_Graph_from_data_obs_rebin3002);
grae->Draw("zp");
tex = new TLatex(0,10,"10^{4}");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,1,"10^{3}");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,0.1,"10^{2}");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,0.01,"10");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,0.001,"1");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,0.0001,"10^{#minus1}");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,1e-05,"10^{#minus2}");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,1e-06,"10^{#minus3}");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0,1e-07,"10^{#minus4}");
tex->SetTextAlign(32);
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->Draw();
TGaxis *gaxis = new TGaxis(1246,2e-08,7866,2e-08,1246,7866,509,"BS");
gaxis->SetLabelOffset(1000);
gaxis->SetLabelSize(0.04);
gaxis->SetTickSize(0.03);
gaxis->SetGridLength(0);
gaxis->SetTitleOffset(1);
gaxis->SetTitleSize(0.04);
gaxis->SetTitleColor(1);
gaxis->SetTitleFont(62);
gaxis->SetMoreLogLabels();
gaxis->Draw();
c_1->Modified();
c->cd();
// ------------>Primitives in pad: c_2
TPad *c_2 = new TPad("c_2", "c_2",0.01,0.02,0.99,0.37);
c_2->Draw();
c_2->cd();
c_2->Range(2.91482,-7.269231,3.947382,3.5);
c_2->SetFillColor(0);
c_2->SetBorderMode(0);
c_2->SetBorderSize(2);
c_2->SetLogx();
c_2->SetGridx();
c_2->SetGridy();
c_2->SetLeftMargin(0.175);
c_2->SetRightMargin(0.05);
c_2->SetTopMargin(0);
c_2->SetBottomMargin(0.35);
c_2->SetFrameBorderMode(0);
c_2->SetFrameBorderMode(0);
Double_t xAxis2[45] = {1246, 1313, 1383, 1455, 1530, 1607, 1687, 1770, 1856, 1945, 2037, 2132, 2231, 2332, 2438, 2546, 2659, 2775, 2895, 3019, 3147, 3279, 3416, 3558, 3704, 3854, 4010, 4171, 4337, 4509, 4686, 4869, 5058, 5253, 5455, 5663, 5877, 6099, 6328, 6564, 6808, 7060, 7320, 7589, 7866};
TH1D *h_fit_residual_vs_mass2 = new TH1D("h_fit_residual_vs_mass2","h_fit_residual_vs_mass",44, xAxis2);
h_fit_residual_vs_mass2->SetBinContent(1,-2522.416);
h_fit_residual_vs_mass2->SetBinContent(2,-5065.52);
h_fit_residual_vs_mass2->SetBinContent(3,-8776.758);
h_fit_residual_vs_mass2->SetBinContent(4,-617.1423);
h_fit_residual_vs_mass2->SetBinContent(5,196.0867);
h_fit_residual_vs_mass2->SetBinContent(6,113.1183);
h_fit_residual_vs_mass2->SetBinContent(7,36.71953);
h_fit_residual_vs_mass2->SetBinContent(8,-26.43266);
h_fit_residual_vs_mass2->SetBinContent(9,-64.89191);
h_fit_residual_vs_mass2->SetBinContent(10,-83.89526);
h_fit_residual_vs_mass2->SetBinContent(11,-82.34386);
h_fit_residual_vs_mass2->SetBinContent(12,-66.64802);
h_fit_residual_vs_mass2->SetBinContent(13,-44.45266);
h_fit_residual_vs_mass2->SetBinContent(14,-18.79395);
h_fit_residual_vs_mass2->SetBinContent(15,-0.3495991);
h_fit_residual_vs_mass2->SetBinContent(16,15.83864);
h_fit_residual_vs_mass2->SetBinContent(17,25.04164);
h_fit_residual_vs_mass2->SetBinContent(18,30.6559);
h_fit_residual_vs_mass2->SetBinContent(19,33.0483);
h_fit_residual_vs_mass2->SetBinContent(20,30.9882);
h_fit_residual_vs_mass2->SetBinContent(21,30.51939);
h_fit_residual_vs_mass2->SetBinContent(22,26.95502);
h_fit_residual_vs_mass2->SetBinContent(23,23.61228);
h_fit_residual_vs_mass2->SetBinContent(24,22.27266);
h_fit_residual_vs_mass2->SetBinContent(25,19.92964);
h_fit_residual_vs_mass2->SetBinContent(26,17.38451);
h_fit_residual_vs_mass2->SetBinContent(27,14.38508);
h_fit_residual_vs_mass2->SetBinContent(28,12.40346);
h_fit_residual_vs_mass2->SetBinContent(29,10.26409);
h_fit_residual_vs_mass2->SetBinContent(30,9.11918);
h_fit_residual_vs_mass2->SetBinContent(31,7.974516);
h_fit_residual_vs_mass2->SetBinContent(32,7.059309);
h_fit_residual_vs_mass2->SetBinContent(33,4.579309);
h_fit_residual_vs_mass2->SetBinContent(34,6.003208);
h_fit_residual_vs_mass2->SetBinContent(35,3.75121);
h_fit_residual_vs_mass2->SetBinContent(36,3.47359);
h_fit_residual_vs_mass2->SetBinContent(37,3.164136);
h_fit_residual_vs_mass2->SetBinContent(38,2.20814);
h_fit_residual_vs_mass2->SetBinContent(39,2.354303);
h_fit_residual_vs_mass2->SetBinContent(40,0.8843693);
h_fit_residual_vs_mass2->SetBinContent(41,-1.306724);
h_fit_residual_vs_mass2->SetBinContent(42,-4.955041);
h_fit_residual_vs_mass2->SetBinContent(43,-26.83887);
h_fit_residual_vs_mass2->SetBinContent(44,-217.8978);
h_fit_residual_vs_mass2->SetBinError(1,1);
h_fit_residual_vs_mass2->SetBinError(2,1);
h_fit_residual_vs_mass2->SetBinError(3,1);
h_fit_residual_vs_mass2->SetBinError(4,1);
h_fit_residual_vs_mass2->SetBinError(5,1);
h_fit_residual_vs_mass2->SetBinError(6,1);
h_fit_residual_vs_mass2->SetBinError(7,1);
h_fit_residual_vs_mass2->SetBinError(8,1);
h_fit_residual_vs_mass2->SetBinError(9,1);
h_fit_residual_vs_mass2->SetBinError(10,1);
h_fit_residual_vs_mass2->SetBinError(11,1);
h_fit_residual_vs_mass2->SetBinError(12,1);
h_fit_residual_vs_mass2->SetBinError(13,1);
h_fit_residual_vs_mass2->SetBinError(14,1);
h_fit_residual_vs_mass2->SetBinError(15,1);
h_fit_residual_vs_mass2->SetBinError(16,1);
h_fit_residual_vs_mass2->SetBinError(17,1);
h_fit_residual_vs_mass2->SetBinError(18,1);
h_fit_residual_vs_mass2->SetBinError(19,1);
h_fit_residual_vs_mass2->SetBinError(20,1);
h_fit_residual_vs_mass2->SetBinError(21,1);
h_fit_residual_vs_mass2->SetBinError(22,1);
h_fit_residual_vs_mass2->SetBinError(23,1);
h_fit_residual_vs_mass2->SetBinError(24,1);
h_fit_residual_vs_mass2->SetBinError(25,1);
h_fit_residual_vs_mass2->SetBinError(26,1);
h_fit_residual_vs_mass2->SetBinError(27,1);
h_fit_residual_vs_mass2->SetBinError(28,1);
h_fit_residual_vs_mass2->SetBinError(29,1);
h_fit_residual_vs_mass2->SetBinError(30,1);
h_fit_residual_vs_mass2->SetBinError(31,1);
h_fit_residual_vs_mass2->SetBinError(32,1);
h_fit_residual_vs_mass2->SetBinError(33,1);
h_fit_residual_vs_mass2->SetBinError(34,1);
h_fit_residual_vs_mass2->SetBinError(35,1);
h_fit_residual_vs_mass2->SetBinError(36,1);
h_fit_residual_vs_mass2->SetBinError(37,1);
h_fit_residual_vs_mass2->SetBinError(38,1);
h_fit_residual_vs_mass2->SetBinError(39,1);
h_fit_residual_vs_mass2->SetBinError(40,1);
h_fit_residual_vs_mass2->SetBinError(41,1);
h_fit_residual_vs_mass2->SetBinError(42,1);
h_fit_residual_vs_mass2->SetBinError(43,1);
h_fit_residual_vs_mass2->SetBinError(44,1);
h_fit_residual_vs_mass2->SetMinimum(-3.5);
h_fit_residual_vs_mass2->SetMaximum(3.5);
h_fit_residual_vs_mass2->SetEntries(44);
h_fit_residual_vs_mass2->SetStats(0);
ci = TColor::GetColor("#ff0000");
h_fit_residual_vs_mass2->SetFillColor(ci);
h_fit_residual_vs_mass2->GetXaxis()->SetTitle("Dijet mass [TeV]");
h_fit_residual_vs_mass2->GetXaxis()->SetRange(1,44);
h_fit_residual_vs_mass2->GetXaxis()->SetMoreLogLabels();
h_fit_residual_vs_mass2->GetXaxis()->SetNoExponent();
h_fit_residual_vs_mass2->GetXaxis()->SetNdivisions(999);
h_fit_residual_vs_mass2->GetXaxis()->SetLabelFont(42);
h_fit_residual_vs_mass2->GetXaxis()->SetLabelOffset(1000);
h_fit_residual_vs_mass2->GetXaxis()->SetLabelSize(0.1);
h_fit_residual_vs_mass2->GetXaxis()->SetTitleSize(0.12);
h_fit_residual_vs_mass2->GetXaxis()->SetTitleFont(42);
h_fit_residual_vs_mass2->GetYaxis()->SetTitle("#frac{(Data-Fit)}{Uncertainty}");
h_fit_residual_vs_mass2->GetYaxis()->SetNdivisions(210);
h_fit_residual_vs_mass2->GetYaxis()->SetLabelFont(42);
h_fit_residual_vs_mass2->GetYaxis()->SetLabelSize(0.1);
h_fit_residual_vs_mass2->GetYaxis()->SetTitleSize(0.12);
h_fit_residual_vs_mass2->GetYaxis()->SetTitleOffset(0.6);
h_fit_residual_vs_mass2->GetYaxis()->SetTitleFont(42);
h_fit_residual_vs_mass2->GetZaxis()->SetLabelFont(42);
h_fit_residual_vs_mass2->GetZaxis()->SetLabelSize(0.035);
h_fit_residual_vs_mass2->GetZaxis()->SetTitleSize(0.035);
h_fit_residual_vs_mass2->GetZaxis()->SetTitleFont(42);
h_fit_residual_vs_mass2->Draw("hist");
tex = new TLatex(2000,-4,"2");
tex->SetTextAlign(22);
tex->SetTextFont(42);
tex->SetTextSize(0.1);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(3000,-4,"3");
tex->SetTextAlign(22);
tex->SetTextFont(42);
tex->SetTextSize(0.1);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(4000,-4,"4");
tex->SetTextAlign(22);
tex->SetTextFont(42);
tex->SetTextSize(0.1);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(5000,-4,"5");
tex->SetTextAlign(22);
tex->SetTextFont(42);
tex->SetTextSize(0.1);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(6000,-4,"6");
tex->SetTextAlign(22);
tex->SetTextFont(42);
tex->SetTextSize(0.1);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(7000,-4,"7");
tex->SetTextAlign(22);
tex->SetTextFont(42);
tex->SetTextSize(0.1);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(8000,-4,"8");
tex->SetTextAlign(22);
tex->SetTextFont(42);
tex->SetTextSize(0.1);
tex->SetLineWidth(2);
tex->Draw();
gaxis = new TGaxis(1246,-3.5,7866,-3.5,1246,7866,509,"BS");
gaxis->SetLabelOffset(1000);
gaxis->SetLabelSize(0.04);
gaxis->SetTickSize(0.03);
gaxis->SetGridLength(0);
gaxis->SetTitleOffset(1);
gaxis->SetTitleSize(0.04);
gaxis->SetTitleColor(1);
gaxis->SetTitleFont(62);
gaxis->SetMoreLogLabels();
gaxis->Draw();
c_2->Modified();
c->cd();
c->Modified();
c->cd();
c->SetSelected(c);
}
|
/** test1i.c --- Init module for test 1.
Christopher League
Test 1 just loads a module, starts it, and closes it.
Both modules say hello, and that's about it.
It also tests Get_char, Kmalloc, and Kfree system calls.
**/
#include "io412.h"
#include "klib.h"
/** Local prototypes, etc. */
typedef int (*PROCPTR)( int, char** );
/** Arguments for children */
int child_argc = 2;
char* child_argv[] = {"test1a", "what a nice day"};
/***
*** Entry point
***/
int Proc( int argc, char** argv )
{
PROCPTR p;
int pid;
char c;
Cprintf( "test1i: Hello!\n" );
Cprintf( "test1i: [Loading test1a...]\n" );
p = Load_module( "test1a.mod" );
Cprintf( "test1i: proc == %p\n", p );
Cprintf( "test1i: [Starting test1a...]\n" );
pid = Proc_start( p, child_argc, child_argv );
Cprintf( "test1i: pid == %d\n", pid );
Cprintf( "test1i: [Closing test1a...]\n" );
Close_module( "test1a.mod" );
Cprintf( "test1i: [Sleeping until keypress...]\n" );
c = Get_char();
Cprintf( "test1i: c == '%c'\n", c );
Cprintf( "test1i: [Terminating...]\n" );
return 0;
}
|
#include <apue.h>
Sigfunc * signal_intr (int signo, Sigfunc *func)
{
struct sigaction act, oact;
act.sa_handler = func;
sigemptyset (&act.sa_mask);
act.sa_flags = 0;
#ifdef SA_INTERRUPT
act.sa_flags |= SA_INTERRUPT;
#endif
if (sigaction (signo, &act, &oact) < 0)
return (SIG_ERR);
return (oact.sa_handler);
}
|
#include <swamp.h>
#include <std.h>
inherit MONSTER;
int wraithgo();
void create() {
::create();
set_name("bog wraith");
set_short("bog wraith");
set_long("Shadowy creatures that haunt the swamp, bog wraiths stand nearly
seven feet tall and wear rotting black robes. They have blood red eyes which
are the only distinguishable facial feature of the wraith.");
set("aggressive", 50);
set_id(({"bog wraith", "wraith"}));
set_class("mage");
set_subclass("sorceror");
set_alignment(-800);
set_skill("psionics", 200);
set_skill("conjuring", 200);
set_skill("healing", 200);
set_stats("intelligence", 100);
set_race("wraith");
set_body_type("human");
if(random(10) > 2) set_gender("male"); else set_gender("female");
set_spell_chance(35);
set_spells(({"solidify", "dissolve", "psistorm", "psidrain"}));
set_level(50);
set_property("no corpse", 1);
set_die("The wraith vanishes!");
}
int wraithgo() {
tell_room(environment(this_object()),"The wraith vanishes!", ({ }));
this_object()->remove();
return 1;
}
|
#include <std.h>
#include <saahr.h>
inherit HOUSE_ROOM;
void create() {
::create();
set_properties(([
"light":2,
"night light":1,
"indoors":0,
"town":1
]));
set_short("a small town");
set_long(
"The river flows nearby beneath a tall willow tree. A small cottage "
"sits in a bed of flowers. The path through this corner of the village "
"loops around from the north to the west."
);
set_items(([
"river" : "A clear river flows to the south.",
({ "tree", "willow", "willow tree" }) :
"The willow tree is very large and droopy. Its small leaves cover "
"a lot of the ground.",
"cottage" : "The cottage is very humble. Its stained wooden exterior "
"looks well worn by time and the elements.",
"flowers" : "Small yellow and white flowers.",
"path" : "The path is very small and seems rarely used.",
]));
set_smell( ({ "default", "flowers" }),
"A light, sweet scent is released by the flowers.");
set_exits(([
"north":VPROOMS"town14_8",
"northeast":VPROOMS"town15_8",
"west":VPROOMS"town13_9",
"enter house":VPROOMS"house14_9"
]));
check_door();
}
|
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <signal.h>
#include <netdb.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <semaphore.h>
/*struct sockaddr_in {
short sin_family; // e.g. AF_INET
unsigned short sin_port; // e.g. htons(3490)
struct in_addr sin_addr; // see struct in_addr, below
char sin_zero[8]; // zero this if you want to
};
struct in_addr {
unsigned long s_addr; // load with inet_aton()
};*/
int main(){
/*char *link;
printf("link: ");
read(0,*link,sizeof(link))
*/
int fd, fdcliente, leido, conectado, connfd, pid;
char buff[1000];
struct sockaddr_in procrem={};
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0 ){
perror ("socket");
return -1;
}
procrem.sin_family = AF_INET;
procrem.sin_port = htons(8080);
//procrem.sin_addr = 192.168.1.52;
procrem.sin_addr.s_addr = htonl(INADDR_ANY);
//inet_pton(AF_INET,"0.0.0.0", &procrem.sin_addr);
int a = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,&a, sizeof a);
if (bind(fd,(struct sockaddr *)&procrem, sizeof procrem) < 0 ) {
perror ("bind");
return -1;
}
listen(fd, 5);
signal(SIGCHLD,SIG_IGN ); //para sacar procesos terminados de la PCB ...
while ( (connfd = accept(fd,NULL, 0)) > 0 ){
pid = fork();
//hijo
if ( pid == 0 ) {
char *p1=NULL,*p2=NULL,*url=NULL,*ancla=NULL,*nuevo_ancla=NULL;
int largo_ancla=0,tam_url=0,tam_ancla=0,tam_oracion=0;
leido = read (connfd,buff ,sizeof buff);
write (1 ,buff ,leido);
char *link=NULL,*ptr=NULL,*palabra_reservada=NULL;
ptr = strtok(buff,"-");
link=ptr;
if((ptr = strtok(NULL,"")) != NULL){
palabra_reservada=ptr;
}
printf("\nlink ->> %s\n",link);
printf("palabra ->> %s\n",palabra_reservada);
p1="http:";
p2="https:";
ptr = strtok(link,"/");
if((strcmp(ptr,p2)==0) || (strcmp(ptr,p1)==0)){
ptr = strtok(NULL,"/");
url=ptr;
printf("url -> %s\n",url);
} else {
url=ptr;
printf("url -> %s\n",url);
}
nuevo_ancla="";
if((ptr = strtok(NULL,"")) != NULL){
ancla=ptr;
largo_ancla=strlen(ancla);
//char nuevo_ancla[largo_ancla+1];
for(int i=0; i<=largo_ancla;i++){
if(i==0){
nuevo_ancla[0]='/';
}else{
nuevo_ancla[i]=ancla[i-1];
}
}
printf("ancla-> %s \n",nuevo_ancla);
tam_ancla=strlen(nuevo_ancla);
}
tam_url=strlen(url);
printf("ancla-> %s \n",nuevo_ancla);
printf("tam url: %d\n",tam_url);
printf("tam ancla: %d\n",tam_ancla);
tam_oracion=40+tam_url+tam_ancla;
char oracion[tam_oracion];
printf("tam oracion: %d\n",tam_oracion);
char part1[]="GET ";
char part2[]=" HTTP/1.1\nHost: ";
char part3[]="\nConnection: close\n\n";
strcpy(oracion,part1);
strcat(oracion,nuevo_ancla);
strcat(oracion,part2);
strcat(oracion,url);
strcat(oracion,part3);
printf("oracion:\n%s \n",oracion);
printf("-----------------\n");
printf("GET /es/ua/fi.html HTTP/1.1\nHost: www.um.edu.ar\nConnection: close\n\n");
//write (connfd ,buff ,leido);
// se conecta como cliente a un servidor http
struct sockaddr_in serverhttp={};
fdcliente = socket(AF_INET, SOCK_STREAM, 0);
if (fdcliente < 0 ){
perror ("socketcliente");
return -1;
}
serverhttp.sin_family = AF_INET;
serverhttp.sin_port = htons(80); //puerto default servidor http
//procrem.sin_addr = 192.168.1.52;
//procrem.sin_addr.s_addr = htonl(0xc0a80134);
//inet_pton(AF_INET,"www.um.eud.ar", &procrem.sin_addr
struct hostent *hp = gethostbyname(url);
if(hp==NULL){
printf("gethostmyname() failed\n");
return 1;
}
inet_pton(AF_INET,inet_ntoa( *( struct in_addr*)( hp -> h_addr_list[0])), &serverhttp.sin_addr);
conectado = connect(fdcliente,(struct sockaddr *)&serverhttp, sizeof serverhttp);
if (conectado < 0 ){
perror ("connect");
return -1;
}
write(fdcliente, "GET /es/ua/fi.html HTTP/1.1\nHost: www.um.edu.ar\nConnection: close\n\n", 67);
while ((leido = read(fdcliente, buff , sizeof buff)) > 0){
if (leido < 0 ){
perror ("read");
return -1;
}
write(connfd,buff,leido);
//parsear palabra
}
return 0;
}
close(connfd);
}
return 0;
}
|
/*
* File: ScreenMasterCommandList.h
* Author: fascio
*
* Created on December 17th, 2014, 19:03
*/
#ifndef __SCREEN_MASTER_COMMAND_LIST_H__
#define __SCREEN_MASTER_COMMAND_LIST_H__
#include "ScreenDisplayDeviceCommandList.h"
//****************************************************************************************
//* COMMAND ID LIST FOR SCREEN MASTER PROTOCOL DEVICE
//****************************************************************************************
#define SCREEN_MASTER_DEVICE_CLIENT_BASE (7000)
#define SCREEN_MASTER_DEVICE_SERVER_BASE (8000)
#define SCREEN_MASTER_DEVICE_SERVER_ERROR_CODE_COMMAND_ID (SCREEN_MASTER_DEVICE_SERVER_BASE + 1)
/*
//****************************************************************************************
//* COMMAND ID FOR SCREEN DISPLAY DEVICE
//****************************************************************************************
#define SCREEN_MASTER_DEVICE_CLIENT_CMD_ID_DSPY_FLOAT_VALUE_UPDATE (SCREEN_MASTER_DEVICE_CLIENT_BASE | 2)
#define SCREEN_MASTER_DEVICE_SERVER_CMD_ID_DSPY_FLOAT_VALUE_UPDATE (SCREEN_MASTER_DEVICE_SERVER_BASE | 2)
//****************************************************************************************
//* COMMAND ID FOR DOT MATRIX DEVICE
//****************************************************************************************
#define SCREEN_MASTER_DEVICE_CLIENT_CMD_ID_DOT_MATRIX_SEND_TEXT (SCREEN_MASTER_DEVICE_CLIENT_BASE | 3)
#define SCREEN_MASTER_DEVICE_SERVER_CMD_ID_DOT_MATRIX_SEND_TEXT (SCREEN_MASTER_DEVICE_SERVER_BASE | 3)
#define SCREEN_MASTER_DEVICE_CLIENT_CMD_ID_DOT_MATRIX_SEND_TEXT_DELAY (SCREEN_MASTER_DEVICE_CLIENT_BASE | 4)
#define SCREEN_MASTER_DEVICE_SERVER_CMD_ID_DOT_MATRIX_SEND_TEXT_DELAY (SCREEN_MASTER_DEVICE_SERVER_BASE | 4)
*/
#endif /* __SCREEN_MASTER_COMMAND_LIST_H__ */
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 4