blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
357
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
58
| license_type
stringclasses 2
values | repo_name
stringlengths 4
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-14 21:31:45
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-01 00:00:00
2023-09-05 23:26:37
| committer_date
timestamp[ns]date 1970-01-01 00:00:00
2023-09-05 23:26:37
| github_id
int64 966
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 24
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-02-03 21:17:16
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 180
values | src_encoding
stringclasses 35
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 6
10.4M
| extension
stringclasses 121
values | filename
stringlengths 1
148
| content
stringlengths 6
10.4M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
39273ba01d42602728fc1404a5ed4ae0388aa2ea
|
188fab8f66082541a4c530a1a2c5e7e2568931b1
|
/code/bubble_7.c
|
5820b75d3b28807010098e2d6ec0bd6216bd1fcc
|
[] |
no_license
|
jaraujouerj/Ponteiros-em-C
|
c65cb10dde111037286c06792de2ba8c47a5681b
|
508d86e6e35ee5139c8e85e8f24fd17a9fb31be2
|
refs/heads/master
| 2023-08-29T09:38:25.185353 | 2021-10-19T23:05:30 | 2021-10-19T23:05:30 | 415,148,550 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,154 |
c
|
bubble_7.c
|
#include <stdio.h>
#include <string.h>
#define MAX_BUF 256
long arr[] = { 3, 6, 1, 2, 3, 8, 4, 1, 7, 2};
#define N1 sizeof(arr) / sizeof(arr[0])
char arr2[][20] = { "Mickey Mouse",
"Pato Donald",
"Minnie Mouse",
"Pateta",
"Ted Jensen",
"João Araujo"
};
#define N2 sizeof(arr2) / sizeof(arr2[0])
void bubble(void* p, int tamanho, int N,
int(*fptr)(const void*, const void*));
int compare_string(const void* m, const void* n);
int compare_long(const void* m, const void* n);
int main(void) {
int i;
puts("\nAntes de ordenar:\n");
for (i = 0; i < N1; i++) { /* mostra os long ints */
printf("%ld ", arr[i]);
}
puts("\n");
for (i = 0; i < N2; i++) { /* mostra as strings */
printf("%s\n", arr2[i]);
}
bubble(arr, 8, N1, compare_long); /* ordena os longs */
bubble(arr2, 20, N2, compare_string); /* ordena as strings */
puts("\n\nApós ordenar:\n");
for (i = 0; i < N1; i++) { /* mostra os longs ordenados */
printf("%ld ", arr[i]);
}
putchar('\n');
for (i = 0; i < N2; i++) { /* mostra as strings ordenadas */
printf("%s\n", arr2[i]);
}
return 0;
}
void bubble(void* p, int tamanho, int n,
int(*fptr)(const void*, const void*)) {
unsigned char buf[MAX_BUF];
unsigned char* bp = p;
for (int i = n - 1; i >= 0; i--) {
for (int j = 1; j <= i; j++) {
int k = fptr((void*)(bp + tamanho * (j - 1)),
(void*)(bp + j * tamanho));
if (k > 0) {
memcpy(buf, bp + tamanho * (j - 1), tamanho);
memcpy(bp + tamanho * (j - 1), bp + j * tamanho, tamanho);
memcpy(bp + j * tamanho, buf, tamanho);
}
}
}
}
int compare_string(const void* m, const void* n) {
char* m1 = (char*)m;
char* n1 = (char*)n;
return (strcmp(m1, n1));
}
int compare_long(const void* m, const void* n) {
long* m1, *n1;
m1 = (long*)m;
n1 = (long*)n;
return (*m1 > *n1);
}
|
e6800b7ec493b5a6fcdca96b71789241a7f92500
|
aabdfa173f8dadf6bdd24d88f36e3c329c65bb7d
|
/KostaClass.d/emb-copti-day1/ch02/02.ptr_st/07.ptrNarray3.c
|
bc1e5f244e063249d166105a1446ed53f1ea832d
|
[] |
no_license
|
RaviKim/CentDir
|
74cf130d80df271f2ee12fb1f80e5f0b30706da2
|
db449e7ba1c04a7a81035d7f3bad5c7a9e831e84
|
refs/heads/master
| 2018-10-22T16:14:05.721894 | 2018-08-07T08:49:01 | 2018-08-07T08:49:01 | 117,939,059 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 360 |
c
|
07.ptrNarray3.c
|
#include <stdio.h>
int main(void)
{
short arr[5] = {1, 2, 3, 4, 5};
short *p = arr;
int i;
for(i=0, p=arr; i<5; i++, p++) {
printf("%d,%d\n", arr[i], *p);
}
p = &arr[0];
printf("p[2] : %d\n", p[2]);
p = &arr[2];
printf("p[2] : %d\n", p[2]);
#ifdef TEST
for(i=0, p=arr; i<5; i++, arr++) {
printf("%d,%d\n", p[i], *arr);
}
#endif
return 0;
}
|
c6d4001bd68e16cc6bcee3173665893597df4389
|
46d84a15cc34213e43c72daae40d6635e8588833
|
/example/qp_example.c
|
6c6694ebdbf4ea2474e45150f9916fd869b4b15b
|
[
"BSD-2-Clause"
] |
permissive
|
shengwen-tw/libqpsolver
|
ab221999e10f918a5809d24a86b9985f7f918e8d
|
a824cf4733d2cd3b6d1edc041b1ef27420b56ca6
|
refs/heads/master
| 2023-01-31T11:43:14.547624 | 2020-12-15T15:27:42 | 2020-12-15T15:27:42 | 304,189,719 | 2 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 2,449 |
c
|
qp_example.c
|
#include <stdio.h>
#include <sys/time.h>
#include <mkl.h>
#include <mkl_lapacke.h>
#include "libqpsolver.h"
#include "matrix.h"
#include "qpsolver.h"
double time(void)
{
static int sec = -1;
struct timeval tv;
gettimeofday(&tv, NULL);
if (sec < 0) sec = tv.tv_sec;
return (tv.tv_sec - sec) + 1.0e-6 * tv.tv_usec;
}
int main(void)
{
/* quadratic programming */
qp_t qp;
qp_set_default(&qp);
//optimization variable
matrix_t x;
matrix_construct(&x, 2, 1, (double []){0,
0});
//objective function
matrix_t P, q;
matrix_construct(&P, 2, 2, (double []){+1, -1,
-1, +2});
matrix_construct(&q, 2, 1, (double []){-2,
-6});
//equaility constraint
matrix_t A_eq, b_eq;
matrix_construct(&A_eq, 1, 2, (double []){1, 1});
matrix_construct(&b_eq, 1, 1, (double []){0});
//inequality constraints
vector_t lb, ub;
matrix_construct(&lb, 2, 1, (double []){-1,
-1});
matrix_construct(&ub, 2, 1, (double []){3.4,
3.3});
matrix_t A, b;
matrix_construct(&A, 3, 2, (double []) {+1, +1,
-1, +2,
+2, +1});
matrix_construct(&b, 3, 1, (double []) {2,
2,
3});
PRINT_MATRIX(x);
PRINT_MATRIX(P);
PRINT_MATRIX(q);
PRINT_MATRIX(A_eq);
PRINT_MATRIX(b_eq);
PRINT_MATRIX(lb);
PRINT_MATRIX(ub);
PRINT_MATRIX(A);
PRINT_MATRIX(b);
/* problem setup */
qp_solve_set_optimization_variable(&qp, &x);
qp_solve_set_cost_function(&qp, &P, &q);
qp_solve_set_equality_constraints(&qp, &A_eq, &b_eq);
qp_solve_set_lower_bound_inequality_constraints(&qp, &lb);
qp_solve_set_upper_bound_inequality_constraints(&qp, &ub);
qp_solve_set_affine_inequality_constraints(&qp, &A, &b);
/* check if start point is in the feasible set */
bool feasible = qp_start_point_feasibility_check(&qp);
if(feasible == false) {
printf("the start point of the problem is infeasible.\n");
/* if the start point is identified as infeasible, the user could
* choose to fix by giving a feasible point or ask the solver to
* calculate one. the latter will increase the computation time. */
}
/* activate the solver */
double start_time = time();
qp_solve_start(&qp);
double end_time = time();
printf("the optimal solution of the problem is:\n");
PRINT_MATRIX(x);
printf("run time: %lf seconds\n"
"phase1 stage took %d iterations\n"
"phase2 stage took %d iterations\n",
end_time - start_time, qp.phase1.iters, qp.phase2.iters + 1);
return 0;
}
|
0009dc7527466ab7b83344de7f8b36dd44a5becf
|
8e919beb9508165dfecf8046d712393a6186b39e
|
/bygfoot/tags/start/bygfoot-unstable/src/gui_functions.c
|
dd6ae597a938150741c0e04b2cf40d07a9fa9795
|
[] |
no_license
|
oznogon/bygfoot
|
ec6b651fe2ffafe5056d699023b5f12423f22145
|
4ae89518277a64ffe7953997a0d3ffb7e0bfc0e3
|
refs/heads/master
| 2021-01-16T23:45:46.635923 | 2014-07-09T20:07:08 | 2014-07-09T20:07:08 | 65,521,922 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 39,145 |
c
|
gui_functions.c
|
/******************************************************************
* Miscellaneous functions that deal with the gui *
******************************************************************/
#include <time.h>
#include <unistd.h>
#include "callbacks.h"
#include "gui_functions.h"
#include "support.h"
/* list of pixmap directories */
static GList *support_directories = NULL;
/* add 'directory' plus subdirectories recursively to the list
we browse when looking for files (e.g. pixmaps) */
void
add_support_directory_recursive (const gchar *directory)
{
GDir *newdir =
g_dir_open(directory, 0, NULL);
const gchar *file;
gchar *fullpath;
if(newdir == NULL)
return;
support_directories = g_list_prepend (support_directories,
g_strdup (directory));
while(TRUE)
{
file = g_dir_read_name(newdir);
if(file == NULL)
break;
fullpath = g_strdup_printf ("%s%s%s", directory,
G_DIR_SEPARATOR_S, file);
if(g_file_test(fullpath, G_FILE_TEST_IS_DIR))
add_support_directory_recursive(fullpath);
g_free(fullpath);
}
g_dir_close(newdir);
}
/* add 'directory' both to our directory list and
GLADE's list */
void
add_support_directory(const gchar *directory)
{
add_pixmap_directory(directory);
add_support_directory_recursive(directory);
}
gchar*
find_support_file (const gchar *filename)
{
GList *elem;
/* We step through each of the pixmaps directory to find it. */
elem = support_directories;
while (elem)
{
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
G_DIR_SEPARATOR_S, filename);
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
return pathname;
g_free (pathname);
elem = elem->next;
}
return NULL;
}
/* keep track whether the game is saved or not */
void
set_save(gboolean status)
{
GtkWidget *button_save =
lookup_widget(main_window, "button_save");
save_status = status;
gtk_widget_set_sensitive(button_save,
(status != 1));
}
/* get an integer from a label */
gint
get_int_from_label(GtkLabel *label)
{
const gchar *string;
gint number;
string = gtk_label_get_text(label);
number = (gint)strtol(string, NULL, 10);
return number;
}
/* set or append 'text' into 'label' */
void
label_set_text(GtkLabel *label, gchar *text, gint append)
{
const gchar *current_text = gtk_label_get_text(label);
gchar buf[BUF_SIZE_SMALL];
strcpy(buf, "");
if(append == 0)
strcpy(buf, text);
else
sprintf(buf, "%s%s", current_text, text);
gtk_label_set_text(label, buf);
}
/* set or append 'number' as text into 'label' */
void
label_set_text_from_int(GtkLabel *label, gint number, gint append)
{
const gchar *current_text = gtk_label_get_text(label);
gchar buf[BUF_SIZE_SMALL];
strcpy(buf, "");
if(append == 0)
sprintf(buf, "%d", number);
else
sprintf(buf, "%s%d", current_text, number);
gtk_label_set_text(label, buf);
}
/* set or append 'number' as text into 'label' */
void
label_set_text_from_float(GtkLabel *label, gfloat number,
gint append, gint precision)
{
const gchar *current_text = gtk_label_get_text(label);
gchar buf[BUF_SIZE_SMALL];
strcpy(buf, "");
if(append == 0)
sprintf(buf, "%.*f", precision, number);
else
sprintf(buf, "%s%.*f", current_text, precision, number);
gtk_label_set_text(label, buf);
}
/* change the 'popups_active' variable. this determines whether
the main window is set sensitive or not */
void
change_popups_active(gint difference)
{
if(main_window == NULL)
return;
popups_active += difference;
if(popups_active == 0)
gtk_widget_set_sensitive(main_window, TRUE);
else
gtk_widget_set_sensitive(main_window, FALSE);
}
/* get the back- and foreground colors
of a table row depending on the rank
it represents */
void
get_table_colors(gint team_id,
gchar *background_color,
gchar *foreground_color)
{
gchar foreground[50],
background[50];
strcpy(foreground, "Black");
strcpy(background, "White");
/* the league leader */
if(team_id < 114 && rank[team_id] == 1)
strcpy(background, "tomato");
/* teams that get promoted or cl teams that
are qualified for the quarter final */
else if( (team_id > 113 && rank[team_id] < 3 && rank[team_id] > 0) ||
(team_id < 20 && rank[team_id] < 5) ||
(team_id < 114 && rank[team_id] < 4) )
strcpy(background, "Lightblue");
/* the teams that would play promotion games */
else if(rank[team_id] < 8 && team_id > 19 && team_id < 114)
strcpy(background, "khaki");
/* thet teams that get relegated */
else if(rank[team_id] >
teams_in_league(get_league_from_id(team_id)) - 4 &&
team_id < 92)
strcpy(background, "Lightgreen");
if(foreground_color != NULL)
strcpy(foreground_color, foreground);
if(background_color != NULL)
strcpy(background_color, background);
}
/* print a message into the message window */
void
print_message(gchar *text)
{
gint i, j;
gchar buf[strlen(text) + 200];
GtkWidget *message_window =
lookup_widget(main_window, "message_window");
for(i = 0; i <= 100 - options[OPT_MESS] * 50; i++)
{
strcpy(buf, "");
for(j=0;j<100 - options[OPT_MESS] * 50 - i;j++)
strcat(buf, " ");
strcat(buf, text);
gtk_entry_set_text(GTK_ENTRY(message_window), buf);
while(gtk_events_pending())
gtk_main_iteration();
usleep(10000);
}
}
/* print a number into an entry field */
void
entry_set_text_from_int(GtkEntry *entry, gint number)
{
gchar buf[BUF_SIZE_SMALL];
sprintf(buf, "%d", number);
gtk_entry_set_text(entry, buf);
}
/* return the entry content as an integer */
gint
entry_get_int(GtkEntry *entry)
{
const gchar *text = gtk_entry_get_text(entry);
gint number = (gint)strtol(text, NULL, 10);
return number;
}
/* set the week number, season number, team name, team league
and team rank labels */
void
set_header(void)
{
gchar buf[BUF_SIZE_SMALL];
GtkWidget *label_season =
lookup_widget(main_window, "label_season");
GtkWidget *label_week =
lookup_widget(main_window, "label_week");
GtkWidget *label_team =
lookup_widget(main_window, "label_team");
GtkWidget *label_league =
lookup_widget(main_window, "label_league");
GtkWidget *label_rank =
lookup_widget(main_window, "label_rank");
GtkWidget *label_money =
lookup_widget(main_window, "label_money");
GtkWidget *eventbox_rank =
lookup_widget(main_window, "eventbox_rank");
GtkWidget *label_av_skill =
lookup_widget(main_window, "label_av_skill");
gchar background_color[50];
GdkColor color;
label_set_text_from_int(GTK_LABEL(label_season), season, 0);
label_set_text_from_int(GTK_LABEL(label_week), week, 0);
label_set_text(GTK_LABEL(label_team), teams[my_team].name, 0);
if(my_team < 130)
label_set_text_from_int(GTK_LABEL(label_rank), rank[my_team], 0);
else
label_set_text(GTK_LABEL(label_rank), "none", 0);
print_grouped_int(finances[FIN_MONEY], buf, 0);
label_set_text(GTK_LABEL(label_money), buf, 0);
if(finances[FIN_MONEY] >= 0)
gdk_color_parse ("black", &color);
else
gdk_color_parse ("Orangered", &color);
gtk_widget_modify_fg (label_money, GTK_STATE_NORMAL, &color);
get_table_colors(my_team, background_color, NULL);
gdk_color_parse(background_color, &color);
gtk_widget_modify_bg(eventbox_rank, GTK_STATE_NORMAL, &color);
get_league_name_from_id(my_team, buf);
label_set_text(GTK_LABEL(label_league), buf, 0);
sprintf(buf, "%.2f %.2f", average_skill(my_team, 11, TRUE),
average_skill(my_team, 20, FALSE));
if(get_place(status, 12) != 13 &&
get_place(status, 12) != 50)
gtk_label_set_text(GTK_LABEL(label_av_skill), buf);
}
/* adjust the widget properties in the main window
(mainly the buttons) depending on the window status
(i.e. in which sub-menu the human player's in) */
void
set_buttons(void)
{
GtkWidget *optionmenu_figures =
lookup_widget(main_window, "optionmenu_figures");
GtkWidget *button_transfer_ok =
lookup_widget(main_window, "button_transfer_ok");
GtkWidget *spin_fee =
lookup_widget(main_window, "spin_fee");
GtkWidget *spin_wage =
lookup_widget(main_window, "spin_wage");
GtkWidget *label_scout_recommends =
lookup_widget(main_window, "label_scout_recommends");
GtkWidget *label_spin =
lookup_widget(main_window, "label_spin");
GtkWidget *button_browse =
lookup_widget(main_window, "button_browse");
GtkWidget *button_browse_back =
lookup_widget(main_window, "button_browse_back");
GtkWidget *player_info_separator =
lookup_widget(main_window, "player_info_separator");
GtkWidget *button_league_results =
lookup_widget(main_window, "button_league_results");
GtkWidget *button_get_loan =
lookup_widget(main_window, "button_get_loan");
GtkWidget *button_fixtures =
lookup_widget(main_window, "button_fixtures");
gtk_widget_hide(button_browse_back->parent->parent);
gtk_widget_hide(button_browse->parent);
gtk_widget_hide(button_transfer_ok->parent);
gtk_widget_hide(spin_wage->parent);
gtk_widget_hide(spin_fee->parent);
gtk_widget_hide(label_scout_recommends);
gtk_widget_hide(player_info_separator);
gtk_widget_hide(button_league_results);
gtk_widget_hide(button_get_loan->parent->parent);
gtk_widget_hide(button_fixtures->parent->parent);
gtk_option_menu_set_history(
GTK_OPTION_MENU(optionmenu_figures), 0);
if(status == 0 || get_place(status, 12) == 50)
gtk_widget_show(player_info_separator);
else if(get_place(status, 6) == 1)
{
gtk_widget_show(button_browse->parent);
if(get_place(status, 5) == 1)
{
gtk_widget_show(button_transfer_ok->parent);
gtk_widget_show(label_scout_recommends);
gtk_widget_show(spin_fee->parent);
gtk_widget_show(spin_wage->parent);
}
else if(get_place(status, 5) == 3)
gtk_widget_show(button_browse_back->parent->parent);
}
else if(get_place(status, 6) == 2)
{
if(get_place(status, 5) == 1)
gtk_widget_show(button_league_results);
if(get_place(status, 5) < 3)
gtk_widget_show(button_fixtures->parent->parent);
if(get_place(status, 5) != 4 ||
season > 2)
gtk_widget_show(button_browse_back->parent->parent);
else
gtk_widget_show(player_info_separator);
}
else if(get_place(status, 6) == 3)
{
gtk_widget_show(button_get_loan->parent->parent);
if(get_place(status, 5) == 1 ||
get_place(status, 5) == 2)
{
gtk_widget_show(button_transfer_ok->parent);
gtk_widget_show(spin_fee->parent);
label_set_text(GTK_LABEL(label_spin), "Max.", 0);
}
}
else if(get_place(status, 6) == 4)
{
gtk_widget_show(button_fixtures->parent->parent);
}
else if(get_place(status, 6) == 6)
{
gtk_widget_show(button_fixtures->parent->parent);
gtk_widget_show(button_browse_back->parent->parent);
}
set_header();
}
/* show the main window with the human player's team in the
player list */
void
initialize_main_window(void)
{
gint i;
GtkWidget *optionmenu_quick_opt =
lookup_widget(main_window, "optionmenu_quick_opt");
GtkWidget *optionmenu_scout =
lookup_widget(main_window, "optionmenu_scout");
GtkWidget *optionmenu_physio =
lookup_widget(main_window, "optionmenu_physio");
GtkWidget *optionmenu_style =
lookup_widget(main_window, "optionmenu_style");
GtkWidget *optionmenu_fixtures =
lookup_widget(main_window, "optionmenu_fixtures");
GtkWidget *entry_structure =
lookup_widget(main_window, "entry_structure");
GtkWidget *quick_opt_items[4];
gint quick_opt_options[4] =
{options[OPT_NOTIFY],
options[OPT_JOBS],
options[OPT_SHOW_LIVE],
options[OPT_OVERWRITE]};
quick_opt_items[0] =
lookup_widget(optionmenu_quick_opt, "menu_item_notify");
quick_opt_items[1] =
lookup_widget(optionmenu_quick_opt, "menu_item_jobs");
quick_opt_items[2] =
lookup_widget(optionmenu_quick_opt, "menu_item_live");
quick_opt_items[3] =
lookup_widget(optionmenu_quick_opt, "menu_item_overwrite");
show_next_opponents();
show_players(NULL, NULL, 0, NULL, 0);
gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu_style),
teams[my_team].style + 2);
gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu_scout),
scout - 1);
gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu_physio),
physio - 1);
gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu_quick_opt),
0);
gtk_option_menu_set_history(GTK_OPTION_MENU(optionmenu_fixtures), 0);
entry_set_text_from_int(GTK_ENTRY(entry_structure),
teams[my_team].structure);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(quick_opt_items[0]),
(quick_opt_options[0] < 100));
for(i=0;i<4;i++)
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(quick_opt_items[i]),
quick_opt_options[i]);
set_header();
}
/* make new bookmaker tips in case the user's
team has changed significantly */
void
bookmaker_re_tip(void)
{
bookmaker_tips[0][0] =
bookmaker_tips[1][0] = -1;
if(status == 0)
on_button_back_to_main_clicked(NULL, NULL);
}
/* show a popup window with an offer for a
player to transfer */
void
make_transfer_offer(gint idx)
{
gchar buf[BUF_SIZE_SMALL];
gint popup_status[3] = {1000000 + idx, -1, -1};
gint player_number = transferlist[idx].player_number;
gfloat value_deviance[2] =
{0.98 - (scout % 10) * 0.03,
1.15 - (scout % 10) * 0.03};
gint value = round_integer(
rnd( teams[my_team].players[player_number].value *
value_deviance[0],
teams[my_team].players[player_number].value *
value_deviance[1] ), 2);
gint team_interested = rndi(0, 174);
while(team_interested == my_team ||
team_interested == 114 ||
team_interested == 130)
team_interested = rndi(0, 174);
popup_status[1] = team_interested;
popup_status[2] = value;
sprintf(buf, "%s are interested in buying %s. They offer ",
teams[team_interested].name,
teams[my_team].players[player_number].name);
print_grouped_int(value, buf, 1);
strcat(buf, " for him, which is ");
print_grouped_int(abs(value - teams[my_team].
players[player_number].value),
buf, 1);
if(value > teams[my_team].players[player_number].value)
strcat(buf, "more ");
else
strcat(buf, "less ");
strcat(buf,
"than the player's value according to your scout. Accept?");
show_popup_window(buf, popup_status);
}
/* check for each player of the human player's team
on the transferlist whether he'll be bought or not */
void
transfer_offers(void)
{
gint i;
/* bad scout: 10% probability ---> best scout: 50% */
gfloat buy_prob =
(gfloat)(scout % 10) * -0.13 + 0.615;
if(week >= 35)
return;
for(i=0;i<20;i++)
if(transferlist[i].time > 0 &&
transferlist[i].team_id == my_team &&
rnd(0,1) < buy_prob)
make_transfer_offer(i);
}
gint
get_current_rank(void)
{
gint i;
for(i=0;i<114;i++)
if(rank_ids[i] == my_team)
return i;
return -1;
}
/* show a popup window with either a job offer
or a note that the human player's been fired */
void
show_job_offer(gint fire)
{
gchar buf[JOB_OFFER_END][BUF_SIZE_SMALL];
gchar buf2[BUF_SIZE_SMALL];
gint new_team = my_team;
gint new_team_bound[2];
/* get the my_team index in the rank_ids array */
gint current_rank =
get_current_rank();
/* if he's been fired, the team to hire him should
be worse than his old one */
new_team_bound[0] = (current_rank - 30 + (fire % 10) * 20 < 0) ?
0 : current_rank - 30 + (fire % 10) * 20;
new_team_bound[1] = (current_rank + 10 + (fire % 10) * 20 > 113) ?
113 : current_rank + 10 + (fire % 10) * 20;
while(new_team == my_team)
new_team = rndi(rank_ids[new_team_bound[0]],
rank_ids[new_team_bound[1]]);
status = 900000 + new_team + 50000 * (fire != 0);
sprintf(buf[JOB_OFFER_ACCEPT], "Accept?");
if(fire != 0)
{
if(fire == 1)
sprintf(buf[JOB_OFFER_TEXT], "The team owners fire you because of unsuccessfulness.");
else if(fire == 11)
sprintf(buf[JOB_OFFER_TEXT], "The team owners fire you because of financial mismanagement.");
sprintf(buf2, "\nBut the owners of %s have heard of your dismissal and would like to hire you. Here's some info on %s:",
teams[new_team].name,
teams[new_team].name);
strcat(buf[JOB_OFFER_TEXT], buf2);
strcat(buf[JOB_OFFER_ACCEPT], " (NOTE: If you don't, the game is over.)");
}
else
sprintf(buf[JOB_OFFER_TEXT], "The owners of %s are impressed by your success with %s. They would like to hire you. Here's some info on %s:",
teams[new_team].name,
teams[my_team].name,
teams[new_team].name);
get_league_name_from_id(new_team, buf2);
strcpy(buf[JOB_OFFER_NAME], teams[new_team].name);
strcpy(buf[JOB_OFFER_LEAGUE], buf2);
sprintf(buf[JOB_OFFER_RANK], "%d", rank[new_team]);
print_grouped_int(
round_integer((gint)rint( rnd(0.7, 0.95) *
(gfloat)stadiums[new_team].capacity * 113), -2),
buf[JOB_OFFER_MONEY],
0);
print_grouped_int(stadiums[new_team].capacity, buf[JOB_OFFER_CAP], 0);
sprintf(buf[JOB_OFFER_SAF], "%.0f%%",
stadiums[new_team].safety * 100);
show_job_offer_window(buf);
}
void
show_fire_warning(void)
{
gchar buf[BUF_SIZE_SMALL];
sprintf(buf, "The team owners are dissatisfied with the team's recent performance. There are rumours they're looking for a new coach.");
show_popup_window(buf, NULL);
}
/* look at the counters and fire the human player
if his team is unsuccessful; or make a job offer
if they're successful */
void
team_offers(void)
{
gint i;
gfloat rndom;
if(abs(counters[COUNT_SUCCESS]) < 45)
return;
if(counters[COUNT_SUCCESS] < -45 &&
counters[COUNT_SUCCESS] > -60 &&
counters[COUNT_WARNING] == 0)
{
show_fire_warning();
counters[COUNT_WARNING] = 1;
return;
}
/* fire */
for(i=0;i<3;i++)
{
rndom = rnd(0,1);
if(counters[COUNT_SUCCESS] <= -95 + i * 10 &&
rndom < 0.8 - i * 0.25)
{
show_job_offer(1);
return;
}
}
if(options[OPT_JOBS] == 0)
return;
/* hire */
rndom = rnd(0,1);
for(i=0;i<3;i++)
{
if(counters[COUNT_SUCCESS] >= 95 - i * 10)
{
if(rndom < 0.3 - i * 0.1)
show_job_offer(0);
return;
}
}
}
/* autosave the game if necessary */
void
update_autosave(void)
{
gchar buf[BUF_SIZE_SMALL];
if(options[OPT_AUTOSAVE] < 0)
return;
counters[COUNT_AUTOSAVE]--;
if(counters[COUNT_AUTOSAVE] > 0)
return;
counters[COUNT_AUTOSAVE] = options[OPT_AUTOSAVE];
sprintf(buf, "%s/.bygfoot/saves/autosave", getenv("HOME"));
save_game(buf);
}
void
get_best_players(gint league, gint best_players[][2])
{
gint i, j;
gint bound[2];
gfloat to_order[480];
gint order[480];
for(i=0;i<480;i++)
to_order[i] = -1;
get_league_bounds(league, bound);
for(i=bound[0];i<bound[1];i++)
for(j=0;j<20;j++)
if(teams[i].players[j].pos >= 0)
{
to_order[(i - bound[0]) * 20 + j] =
(gfloat)teams[i].players[j].goals;
if(teams[i].players[j].games > 0)
to_order[(i - bound[0]) * 20 + j] +=
((gfloat)teams[i].players[j].goals /
((gfloat)teams[i].players[j].games * 10));
}
sort_float_array(to_order, order, 0, 479);
j = 0;
for(i=0;i<480;i++)
if(teams[bound[0] + (order[i] - order[i] % 20) / 20].
players[order[i] % 20].pos > 0 && j < 10 &&
to_order[order[i]] != -1)
{
best_players[j][0] =
bound[0] + (order[i] - order[i] % 20) / 20;
best_players[j][1] = order[i] % 20;
j++;
}
j = 0;
for(i=479;i>=0;i--)
if(teams[bound[0] + (order[i] - order[i] % 20) / 20].
players[order[i] % 20].pos == 0 &&
teams[bound[0] + (order[i] - order[i] % 20) / 20].
players[order[i] % 20].games >=
(gfloat)teams[bound[0] + (order[i] - order[i] % 20) / 20].
results[RES_GAM] / 2 && j < 10 &&
to_order[order[i]] != -1)
{
best_players[10 + j][0] =
bound[0] + (order[i] - order[i] % 20) / 20;
best_players[10 + j][1] = order[i] % 20;
j++;
}
}
void
show_results(gint page)
{
if( (page == 3 && options[OPT_SHOW_MY_GAMES] == 0)
|| page == 0 )
{
show_fixtures(week - 1);
status = 600011;
}
else if( (page == 3 && options[OPT_SHOW_MY_GAMES] == 1)
|| page == 1 )
{
callback_show_preview();
status = 600010;
}
}
/* update some variables each week */
void
update_variables(void)
{
gint i, j;
for(i=0;i<2;i++)
for(j=0;j<2;j++)
bookmaker_tips[i][j] = -1;
}
void
finance_events(void)
{
gint i;
gchar buf[BUF_SIZE_SMALL];
gchar buf2[BUF_SIZE_SMALL];
if(counters[COUNT_LOAN] == 0)
show_popup_window("You've got to pay back your loan NOW!!!",
NULL);
if(counters[COUNT_LOAN] == -1 ||
counters[COUNT_POSITIVE] == -1 ||
counters[COUNT_OVERDRAWN] == 4)
{
show_job_offer(11);
return;
}
if(counters[COUNT_POSITIVE] == 0)
show_popup_window(
"Your bank account has to exceed your drawing credit next week!!!",
NULL);
for(i=0;i<3;i++)
if(counters[COUNT_OVERDRAWN] == i + 1 &&
counters[COUNT_POSITIVE] == 6 - i * 2)
{
if(counters[COUNT_OVERDRAWN] == 1)
sprintf(buf, "You have overdrawn your bank account. ");
else
sprintf(buf, "You have overdrawn your bank account once again. ");
sprintf(buf2, "The team owners give you %d weeks to get positive.",
counters[COUNT_POSITIVE]);
strcat(buf, buf2);
show_popup_window(buf, NULL);
}
}
gboolean
my_team_will_play(void)
{
gint i;
for(i = FIX_END - 1; i >= 0; i--)
if(fixtures[i].type != -1 &&
my_team_involved(fixtures[i]) &&
fixtures[i].week_number > week)
return TRUE;
return FALSE;
}
/* find out the winners of the promotion games */
void
get_promotion_winners(gint *promotion_winners)
{
gint i, k;
k = 0;
for(i=0;i<FIX_END;i++)
if(fixtures[i].type > 55000 &&
fixtures[i].type < 60000 &&
fixtures[i].type % 10 == 5)
{
promotion_winners[k] = winner_of(fixtures[i]);
k++;
}
}
/* promotions and relegations */
void
season_end_prom_rel(void)
{
gint i, j;
gint limits[4] = {20, 44, 68, 92};
gint promotion_winners[4];
gint my_old_league =
get_league_from_id(my_team);
/* swap the first and last three
in the tables */
for(i=0;i<4;i++)
for(j=0;j<3;j++)
swap_teams(rank_ids[limits[i] + j],
rank_ids[limits[i] - j - 1]);
get_promotion_winners(promotion_winners);
for(i=0;i<4;i++)
swap_teams(promotion_winners[i], rank_ids[limits[i] - 4]);
/* reward or punish the human player if he's
promoted or relegated */
if(my_old_league < get_league_from_id(my_team))
counters[COUNT_SUCCESS] -= 30;
else if(my_old_league > get_league_from_id(my_team))
counters[COUNT_SUCCESS] += 30;
}
/* generate new european teams
and get the right engl. teams */
void
season_end_euro(void)
{
gint i;
/* set english participants */
teams[114].id = rank_ids[0];
/* if there's a double winner the runner-up takes part
in the CWC */
teams[130].id = (get_winner_runner_up(9000, 1) == rank_ids[0]) ?
get_winner_runner_up(9000, 0) :
get_winner_runner_up(9000, 1);
for(i=0;i<3;i++)
if(rank_ids[i + 1] != teams[130].id)
teams[175 + i].id = rank_ids[i + 1];
else
teams[175 + i].id = rank_ids[4];
fill_in_euro_teams();
}
/* nullify some counters and
number of games and goals etc. */
void
season_end_nullify(void)
{
gint i, j;
counters[COUNT_OVERDRAWN] =
counters[COUNT_WARNING] = 0;
if(counters[COUNT_SUCCESS] > 100)
counters[COUNT_SUCCESS] = 100;
for(i=0;i<130;i++)
{
for(j=0;j<RES_END;j++)
teams[i].results[j] = 0;
for(j=0;j<20;j++)
{
teams[i].players[j].games =
teams[i].players[j].goals =
teams[i].players[j].booked = 0;
}
}
for(i=0;i<178;i++)
stadiums[i].games =
stadiums[i].average_attendance = 0;
for(i=0;i<FIX_END;i++)
fixtures[i].type = -1;
for(i=0;i<50;i++)
{
goals[0][i].minute = goals[1][i].minute = -1;
if(i<20)
transferlist[i].time = -1;
if(i<11)
injuries[i] = booked[i] = -1;
if(i<2)
stadium_facts[i][0] =
stadium_facts[i][1] = 0;
if(i > FIN_MONEY && i < FIN_DEBTS)
finances[i] = 0;
}
}
void
change_player(player *pl, gfloat factor)
{
pl->skill =
pl->cskill =
pl->skill * factor;
if(pl->skill > 9.9)
pl->skill =
pl->cskill = rnd(9.7, 9.9);
pl->etal =
estimate_talent(*pl);
pl->value = assign_value(*pl);
pl->wage = assign_wage(*pl);
}
/* change each team slightly to have
something new in the new season */
void
season_end_change_teams(void)
{
gint i, j;
gfloat factor;
for(i=0;i<114;i++)
if(i != my_team)
{
factor = rnd(0.92, 1.08);
/* if the human player's the
champion, make the other teams rather
better than worse */
if(rank_ids[0] == my_team && i < 20)
factor += 0.04;
for(j=0;j<20;j++)
change_player(&(teams[i].players[j]), factor);
}
}
season_stat*
get_new_stat(void)
{
season_stat *stat = history;
if(history == NULL)
{
stat = (season_stat*)g_malloc(sizeof(season_stat));
stat->next = NULL;
history = stat;
return stat;
}
while(stat->next != NULL)
stat = stat->next;
stat->next = (season_stat*)g_malloc(sizeof(season_stat));
stat->next->next = NULL;
return stat->next;
}
void
history_get_champions(season_stat *stat)
{
gint i;
/* english champions */
strcpy(stat->team_names[STAT_PREM],
teams[rank_ids[0]].name);
strcpy(stat->team_names[STAT_NAT_CONF],
teams[rank_ids[92]].name);
for(i=0;i<3;i++)
strcpy(stat->team_names[STAT_DIV1 + i],
teams[rank_ids[20 + i * 24]].name);
/* fa cup, league cup, charity shield */
strcpy(stat->team_names[STAT_FA],
teams[get_winner_runner_up(9000, 1)].name);
strcpy(stat->team_names[STAT_LEAGUE],
teams[get_winner_runner_up(11000, 1)].name);
strcpy(stat->team_names[STAT_CHARITY],
teams[get_winner_runner_up(25000, 1)].name);
/* european champions */
strcpy(stat->team_names[STAT_CL],
teams[get_winner_runner_up(6000, 1)].name);
strcpy(stat->team_names[STAT_CWC],
teams[get_winner_runner_up(7000, 1)].name);
strcpy(stat->team_names[STAT_UEFA],
teams[get_winner_runner_up(8815, 1)].name);
strcpy(stat->team_names[STAT_SUPERCUP],
teams[get_winner_runner_up(35000, 1)].name);
}
void
history_get_best_players(season_stat *stat)
{
gint i, j, k;
gint best_players[20][2];
for(k=0;k<2;k++)
for(i=0;i<5;i++)
{
get_best_players(i + 1, best_players);
for(j=0;j<3;j++)
{
stat->best_players[k * 15 + i * 3 + j].games =
teams[best_players[k * 10 + j][0]].
players[best_players[k * 10 + j][1]].games;
stat->best_players[k * 15 + i * 3 + j].goals =
teams[best_players[k * 10 + j][0]].
players[best_players[k * 10 + j][1]].goals;
strcpy(stat->best_players[k * 15 + i * 3 + j].name,
teams[best_players[k * 10 + j][0]].
players[best_players[k * 10 + j][1]].name);
strcpy(stat->best_players[k * 15 + i * 3 + j].team_name,
teams[best_players[k * 10 + j][0]].name);
}
}
}
/* return the rank of the human player if
he's played in a regular championship
or his result if he's played in a cup only */
gint
history_get_rank(void)
{
gint i;
gint int_cup;
if(my_team < 114)
return rank[my_team];
if(my_team < 130)
int_cup = 6;
else if(my_team < 145)
int_cup = 7;
else
int_cup = 8;
for(i = FIX_END - 1; i >= 0; i--)
if(my_team_involved(fixtures[i]) &&
get_place(fixtures[i].type, 11) == int_cup)
break;
if(i == -1)
return 0;
if(get_place(fixtures[i].type, 12) == 65)
return 65;
return get_place(fixtures[i].type, 12) *
(1 - 2 * (winner_of(fixtures[i]) == my_team));
}
/* fill in a new history element at
the end of the season with cup winners
and champions etc. */
void
write_new_history(void)
{
season_stat *stat =
stat = get_new_stat();
stat->season_number = season;
stat->my_league = get_league_from_id(my_team);
stat->my_rank = history_get_rank();
strcpy(stat->team_names[STAT_MY_TEAM], teams[my_team].name);
history_get_champions(stat);
history_get_best_players(stat);
}
/* end a season and begin a new one by promoting /
relegating the appropriate teams; find out who's
participating in the european cups, write new fixtures
etc. */
void
season_end(void)
{
write_new_history();
/* promotions and relegations */
season_end_prom_rel();
/* change each team slightly to have
something new in the new season */
season_end_change_teams();
/* generate new european teams
and get the right engl. teams */
season_end_euro();
/* nullify some counters and
number of games and goals etc. */
season_end_nullify();
write_season_fixtures();
}
/* change the country in the team selection window
when the user clicks on a flag */
void
change_country_team_selection(GtkWidget *button)
{
gint i;
GtkWidget *radiobutton_country[TEXT_FILES_PLAYER_NAMES];
GtkWidget *team_selection_treeview =
lookup_widget(button, "team_selection_treeview");
radiobutton_country[TEXT_FILES_COUNTRY_ENG] =
lookup_widget(button, "radiobutton_country0");
radiobutton_country[TEXT_FILES_COUNTRY_DE] =
lookup_widget(button, "radiobutton_country1");
radiobutton_country[TEXT_FILES_COUNTRY_IT] =
lookup_widget(button, "radiobutton_country2");
radiobutton_country[TEXT_FILES_COUNTRY_FR] =
lookup_widget(button, "radiobutton_country3");
radiobutton_country[TEXT_FILES_COUNTRY_ES] =
lookup_widget(button, "radiobutton_country4");
radiobutton_country[TEXT_FILES_COUNTRY_RO] =
lookup_widget(button, "radiobutton_country5");
radiobutton_country[TEXT_FILES_COUNTRY_BR] =
lookup_widget(button, "radiobutton_country6");
radiobutton_country[TEXT_FILES_COUNTRY_PL] =
lookup_widget(button, "radiobutton_country7");
for(i=0;i<TEXT_FILES_PLAYER_NAMES;i++)
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton_country[i])))
country_names(i, "");
show_team_list(team_selection_treeview, 0);
}
gint
get_game_end(gint idx)
{
gint i;
gint goal_idx =
get_statistics_variable_index(fixtures[idx]);
if(is_draw(fixtures[idx], 0))
return 120;
for(i=0;i<50;i++)
if(goals[goal_idx][i].minute < 0)
break;
if(i == 0)
return rndi(90, 95);
return (goals[goal_idx][i - 1].minute >= 90) ?
goals[goal_idx][i - 1].minute + rndi(1, 2) :
rndi(90, 95);
}
/* get the left/right probabilitiy for the tendency bar */
gfloat
get_tendency_prob(gint idx, gdouble value)
{
gfloat attack_value[2];
gfloat defend_value[2];
gfloat goalie_value[2];
gfloat home_advantage[2] = {1, 1};
if(fixtures[idx].type % 1000 != 0 ||
fixtures[idx].type < 6000)
home_advantage[0] =
gauss_dist(1.05, 1.05, 1.15, 1.15);
prg_calculate_att_def(fixtures[idx], attack_value,
defend_value, goalie_value,
home_advantage);
if(value == 0.5)
return (attack_value[1] + defend_value[1]) /
(attack_value[0] + defend_value[0] +
attack_value[1] + defend_value[1]);
if(value < 0.5)
return attack_value[1] / (attack_value[1] + defend_value[0]);
return attack_value[0] / (attack_value[0] + defend_value[1]);
}
/* get a new value for the tendency bar in the live game window */
gdouble
update_tendency(GtkWidget *hscale_tendency,
gint minute, gint idx, gdouble *old_values,
gfloat stick_prob)
{
gint i;
gint goal_idx =
get_statistics_variable_index(fixtures[idx]);
gint next_goal = 150;
gint previous_goal = -100;
gint team_id = 0;
gint steps_to_goal;
gint minutes_to_goal;
gfloat prob;
gfloat rndom;
gdouble current_value =
gtk_range_get_value(GTK_RANGE(hscale_tendency));
gdouble new_value;
GdkColor color;
prob = get_tendency_prob(idx, current_value);
/* get the time of the next and previous goals */
for(i=0;i<50;i++)
if(goals[goal_idx][i].minute >= minute)
{
next_goal = goals[goal_idx][i].minute;
team_id = (goals[goal_idx][i].team_id ==
fixtures[idx].team_id[0]) ?
1 : 0;
break;
}
for(i=49;i>=0;i--)
if(goals[goal_idx][i].minute < minute &&
goals[goal_idx][i].minute > 0)
{
previous_goal = goals[goal_idx][i].minute;
break;
}
if(current_value == 0 || current_value == 1 ||
next_goal == minute)
{
gdk_color_parse("red", &color);
gtk_widget_modify_bg(hscale_tendency,
GTK_STATE_NORMAL, &color);
}
else
{
gdk_color_parse("Lightgrey", &color);
gtk_widget_modify_bg(hscale_tendency,
GTK_STATE_NORMAL, &color);
}
if(next_goal == minute)
return team_id;
else if(minute - previous_goal < 4)
return current_value;
else if(minute - previous_goal < 6)
return 0.5;
steps_to_goal =
(gint)fabs((current_value - (gdouble)team_id) * 20);
minutes_to_goal = next_goal - minute;
if(minutes_to_goal <= steps_to_goal)
return fabs(team_id - (gdouble)minutes_to_goal / 20);
if(steps_to_goal - minutes_to_goal < 6)
prob += 0.15 * (1 - 2 * team_id);
else if(steps_to_goal - minutes_to_goal < 11)
prob += 0.1 * (1 - 2 * team_id);
if(old_values[0] != old_values[1])
prob += (stick_prob * (old_values[0] - old_values[1]) * 20);
rndom = rnd(0,1);
if(rndom < prob - 0.05)
new_value = current_value - 0.05;
else if(rndom > prob + 0.05)
new_value = current_value + 0.05;
else
new_value = current_value;
if(new_value > 0.95)
new_value = 0.98;
if(new_value < 0.05)
new_value = 0.02;
return new_value;
}
void
show_live_game(gint idx)
{
gint i, j, k;
gint game_end;
gint length;
gint goal_idx =
get_statistics_variable_index(fixtures[idx]);
gdouble old_values[2] = {0, 0};
gdouble new_value = 0;
gfloat stick_prob = (gfloat)rndi(1, 3) / 10 + 0.05;
gchar buf[BUF_SIZE_SMALL],
buf2[BUF_SIZE_SMALL], buf3[BUF_SIZE_SMALL];
GtkWidget *live_window =
return_live_window();
GtkWidget *ruler =
lookup_widget(live_window, "hruler_live");
GtkWidget *progressbar_live =
lookup_widget(live_window, "progressbar_live");
GtkWidget *hscale_tendency =
lookup_widget(live_window, "hscale_tendency");
GtkWidget *button_live_close =
lookup_widget(live_window, "button_live_close");
GtkWidget *check_live_window_tendency =
lookup_widget(live_window, "check_live_window_tendency");
game_end = get_game_end(idx);
if(fixtures[idx].type < 6000 ||
get_place(fixtures[idx].type, 12) == 65)
length = 97;
else
length = 121;
if(options[OPT_LIVE_TENDENCY] == 0)
{
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(check_live_window_tendency),
FALSE);
gtk_widget_hide(hscale_tendency);
}
else
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(check_live_window_tendency),
TRUE);
gtk_ruler_set_range(GTK_RULER(ruler),
0, length, 0, length);
strcpy(buf, "");
strcpy(buf2, "");
fixture_type_to_string(fixtures[idx].type,
0, buf);
fixture_type_to_string(fixtures[idx].type,
1, buf2);
sprintf(buf3, "%s %s", buf, buf2);
gtk_window_set_title(GTK_WINDOW(live_window), buf3);
change_popups_active(1);
gtk_widget_show(live_window);
for(i=0;i<game_end * 4;i++)
{
gtk_progress_bar_set_fraction(
GTK_PROGRESS_BAR(progressbar_live),
(gdouble)i / (length * 4));
if(i % 4 == 0)
{
new_value = update_tendency(hscale_tendency,
i / 4, idx, old_values,
stick_prob);
gtk_range_set_value(GTK_RANGE(hscale_tendency), new_value);
old_values[0] = old_values[1];
old_values[1] = new_value;
show_live_window(live_window, idx, i / 4);
}
while(gtk_events_pending())
gtk_main_iteration();
usleep(25000 + options[OPT_LIVE_DURATION] * 240);
}
/* no penalties*/
if(fixtures[idx].result[0][2] +
fixtures[idx].result[1][2] == 0)
{
gtk_widget_show(button_live_close->parent);
return;
}
for(i=0;i<50;i++)
if(goals[goal_idx][i].type > 1)
break;
for(k=i;k<50;k++)
if(goals[goal_idx][k].minute > 0)
{
for(j=1;j<3;j++)
{
show_live_window(live_window, idx, j * 1000 + k + 1);
while(gtk_events_pending())
gtk_main_iteration();
usleep(1300000);
}
}
gtk_widget_show(button_live_close->parent);
}
/* show a live game */
void
live_game(gint number)
{
gint i, k;
gint idx[2] = {-1, -1};
if(number == 0)
status = -100000;
k = 0;
for(i=FIX_END - 1;i>=0;i--)
if(my_team_involved(fixtures[i]) &&
fixtures[i].week_number == week)
{
idx[k] = i;
k++;
}
/* no more games to show,
so we set the status appropriately */
if(idx[number] == -1)
{
status = -50000;
return;
}
show_live_game(idx[number]);
/* we have already shown the second game of the week
or we only had one game this week */
if(number == 1 || idx[1] == -1)
status = -50000;
return;
}
/* start a new week: compute games etc. */
void
callback_new_week(gboolean calculate)
{
GtkWidget *player_list =
lookup_widget(main_window, "player_list");
if(calculate)
{
if(my_team_played(week))
gtk_tree_view_set_model(GTK_TREE_VIEW(player_list),
NULL);
if(my_team_played(week) || my_team > 114)
update_finances();
update_stadium();
process_week_games(week);
if(options[OPT_SHOW_LIVE] == 1)
{
live_game(0);
return;
}
}
update_ranks();
update_fixtures();
update_teams();
week++;
update_transferlist();
prize_money();
if(options[OPT_SKIP_WEEKS] == 1 ||
!my_team_will_play())
while(!my_team_played(week) &&
!my_team_played(week - 1) && week < 49)
{
process_week_games(week);
update_ranks();
update_fixtures();
update_teams();
week++;
update_transferlist();
}
transfer_offers();
update_counters();
team_offers();
finance_events();
update_scout();
update_autosave();
update_variables();
/* player wasn't fired */
if( status < 900000 &&
(my_team_played(week - 1) ||
my_team_played(week)) )
{
if(my_team_played(week - 1))
show_results(3);
else if(week < 49)
callback_show_preview();
}
if(week == 50)
{
season_end();
season++;
week = 1;
}
if(stadiums[my_team].safety < (gfloat)options[OPT_DUMMY1] / 100)
show_popup_window("Your stadium safety's low. ", NULL);
}
|
76cfe5a6ca070342de5f2988ba652b2b7bb95961
|
a364f5e25e4ec3563c2a6e366069488786927948
|
/sys/dev/bi/bi.c
|
76039a72d81bb35e5b6b2bc6eb9f4d3c95c0eedf
|
[] |
no_license
|
noud/mouse-bsd
|
b044db5ba4085794b94ea729eb4148e1c86d73b5
|
a16ee9b253dbd25c931216ef9be36611fb847411
|
refs/heads/main
| 2023-02-24T06:22:20.517329 | 2020-08-25T20:21:40 | 2020-08-25T20:21:40 | 334,500,331 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 4,191 |
c
|
bi.c
|
/* $NetBSD: bi.c,v 1.13 1999/08/04 19:12:22 ragge Exp $ */
/*
* Copyright (c) 1996 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed at Ludd, University of
* Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* VAXBI specific routines.
*/
/*
* TODO
* handle BIbus errors more gracefully.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <dev/bi/bireg.h>
#include <dev/bi/bivar.h>
static int bi_print __P((void *, const char *));
struct bi_list bi_list[] = {
{BIDT_MS820, 1, "ms820"},
{BIDT_DRB32, 0, "drb32"},
{BIDT_DWBUA, 0, "dwbua"},
{BIDT_KLESI, 0, "klesi"},
{BIDT_KA820, 1, "ka820"},
{BIDT_DB88, 0, "db88"},
{BIDT_CIBCA, 0, "cibca"},
{BIDT_DMB32, 0, "dmb32"},
{BIDT_CIBCI, 0, "cibci"},
{BIDT_KA800, 0, "ka800"},
{BIDT_KDB50, 0, "kdb50"},
{BIDT_DWMBA, 0, "dwmba"},
{BIDT_KFBTA, 0, "kfbta"},
{BIDT_DEBNK, 0, "debnk"},
{BIDT_DEBNA, 0, "debna"},
{0,0,0}
};
int
bi_print(aux, name)
void *aux;
const char *name;
{
struct bi_attach_args *ba = aux;
struct bi_list *bl;
for (bl = &bi_list[0]; bl->bl_nr; bl++)
if (bl->bl_nr == bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0))
break;
if (name) {
if (bl->bl_nr == 0)
printf("unknown device 0x%x",
bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0));
else
printf(bl->bl_name);
printf(" at %s", name);
}
printf(" node %d", ba->ba_nodenr);
#ifdef DEBUG
if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
printf(" [sadr %x eadr %x]",
bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
#endif
return bl->bl_havedriver ? UNCONF : UNSUPP;
}
static int lastiv = 0;
void
bi_attach(sc)
struct bi_softc *sc;
{
struct bi_attach_args ba;
int nodenr;
printf("\n");
ba.ba_iot = sc->sc_iot;
ba.ba_busnr = sc->sc_busnr;
/*
* Interrupt numbers. All vectors from 256-512 are free, use
* them for BI devices and just count them up.
* Above 512 are only interrupt vectors for unibus devices.
* Is it realistic with more than 64 BI devices???
*/
for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
NODESIZE, 0, &ba.ba_ioh)) {
printf("bi_attach: bus_space_map failed, node %d\n",
nodenr);
return;
}
if (badaddr((caddr_t)ba.ba_ioh, 4)) {
bus_space_unmap(sc->sc_iot, ba.ba_ioh, NODESIZE);
} else {
ba.ba_nodenr = nodenr;
ba.ba_ivec = 256 + lastiv;
lastiv += 4;
config_found(&sc->sc_dev, &ba, bi_print);
}
}
}
|
8a19b5f397efcffad2a33a2618e4c6edf7a5f94e
|
8cd60da4b2c55c95cd4537473049cea10de686ac
|
/Pods/Headers/Private/Kanna/HTMLtree.h
|
201765c30e838c7dcf5621f3584ee841d8bf58de
|
[] |
no_license
|
sjcode/Social8080Swift
|
6f37daf1e3dc23ab2dacf5e623e763da22167d99
|
fce7fe1c071baa190575451c374def408282ee42
|
refs/heads/master
| 2021-01-11T17:28:48.211806 | 2017-01-23T08:17:59 | 2017-01-23T08:17:59 | 79,782,783 | 4 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 40 |
h
|
HTMLtree.h
|
../../../Kanna/Sources/libxml/HTMLtree.h
|
5081dfb30d2fd885c491a678e14446e8379f7727
|
910964abab8a891bd3889cf279f9d44546c4a5e7
|
/Ch2/Projects/Project_02.c
|
2a83d2daf69ed28696d72a614eb402581da11410
|
[] |
no_license
|
wozhijiebaigei/C-Programming-A-Modern-Approach
|
a198de27a5d7711c2f095806c4c9c01e3a3c371d
|
ca264e80d185caed79d50bbcc3dfa0971f7f6ddf
|
refs/heads/master
| 2021-06-14T03:33:16.323042 | 2017-02-12T19:37:40 | 2017-02-12T19:37:40 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 353 |
c
|
Project_02.c
|
/* Name: Project02
* Purpose: Compute the volume of a 10 meter radius sphere using the formula v = 4/3(pi)*r^3
* Autohor K Sze
*/
#include <stdio.h>
#define RADIUS 10
int main(void)
{
float volume;
volume = ((4.0f/3.0f) * 3.1415 * (RADIUS * RADIUS * RADIUS));
printf("Volume of a 10 meter radius sphere is: %.2f\n", volume);
return 0;
}
|
fdf0d6029509534725d15d669db9a11768191e0d
|
c5cb98b0eecce668f76b8de1e9dc88d64971b3a9
|
/include/ach/generic.h
|
95b1530e4d73618dde766f79b173bc36a006084a
|
[
"BSD-3-Clause"
] |
permissive
|
dyalab/ach
|
ef84058748b6a1797e8b1b3757096584a45ef9ab
|
a2ed5cdb9599186fc30a0d20a4e2d9d629a3695f
|
refs/heads/master
| 2020-09-11T08:10:57.584240 | 2019-11-15T20:51:14 | 2019-11-15T20:51:14 | 222,000,464 | 0 | 0 |
BSD-3-Clause
| 2019-11-15T20:45:27 | 2019-11-15T20:45:26 | null |
UTF-8
|
C
| false | false | 9,398 |
h
|
generic.h
|
/* -*- mode: C; c-basic-offset: 4 -*- */
/* ex: set shiftwidth=4 tabstop=4 expandtab: */
/*
* Copyright (c) 2008-2014, Georgia Tech Research Corporation
* Copyright (c) 2015, Rice University
* Copyright (c) 2015, Atlas Copco Rock Drills AB
* All rights reserved.
*
* Author(s): Neil T. Dantam <[email protected]>
* Mattias <[email protected]>
* Georgia Tech Humanoid Robotics Lab
* Under Direction of Prof. Mike Stilman <[email protected]>
*
*
* This file is provided under the following "BSD-style" License:
*
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* * Neither the name of the copyright holder the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
/** \file generic.h
*
* \brief This file contains declarations needed by both the
* userspace public interface and the Linux kernel
* implementation.
*
* \author Neil T. Dantam
*/
#ifndef ACH_GENERIC_H
#define ACH_GENERIC_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __GNUC__
/** Warn if result is unused */
#define ACH_WARN_UNUSED __attribute__((warn_unused_result))
#else
/** Warn if result is unused */
#define ACH_WARN_UNUSED
#endif /* __GNUC__ */
#ifdef CONFIG_COMPAT
#include <linux/compat.h>
#endif /* CONFIG_COMPAT */
/** return status codes for ach functions.
*
* \see enum ach_mask
*/
typedef enum ach_status {
ACH_OK = 0, /**< Call successful */
ACH_OVERFLOW = 1, /**< destination too small to hold frame */
ACH_INVALID_NAME = 2, /**< invalid channel name */
ACH_BAD_SHM_FILE = 3, /**< channel file didn't look right */
ACH_FAILED_SYSCALL = 4, /**< a system call failed */
ACH_EAGAIN = 5, /**< no new data in the channel */
ACH_MISSED_FRAME = 6, /**< we missed the next frame */
ACH_TIMEOUT = 7, /**< timeout before frame received */
ACH_EEXIST = 8, /**< channel file already exists */
ACH_ENOENT = 9, /**< channel file doesn't exist */
ACH_CLOSED = 10, /**< unused */
ACH_BUG = 11, /**< internal ach error */
ACH_EINVAL = 12, /**< invalid parameter */
ACH_CORRUPT = 13, /**< channel memory has been corrupted */
ACH_BAD_HEADER = 14, /**< an invalid header was given */
ACH_EACCES = 15, /**< permission denied */
ACH_CANCELED = 16, /**< operation canceled */
ACH_EFAULT = 17, /**< bad address for data copy */
ACH_EINTR = 18, /**< operation interrupted. Only used
* internally and not returned to
* library callers. */
ACH_ENOTSUP = 19, /**< not supported.*/
} ach_status_t;
#define ACH_STALE_FRAMES ACH_EAGAIN
#define ACH_LOCKED ACH_EAGAIN
/** Generate a bit mask from an ach status type.
*
* \see enum ach_mask
*/
#define ACH_STATUS_MASK(r) (1<<(r))
/** Bit masks that correspond to members of enum ach_status.
*
* These masks are useful to check whether a status code matches a
* set of values.
*/
enum ach_mask {
ACH_MASK_OK = ACH_STATUS_MASK(ACH_OK),
ACH_MASK_OVERFLOW = ACH_STATUS_MASK(ACH_OVERFLOW),
ACH_MASK_INVALID_NAME = ACH_STATUS_MASK(ACH_INVALID_NAME),
ACH_MASK_BAD_SHM_FILE = ACH_STATUS_MASK(ACH_BAD_SHM_FILE),
ACH_MASK_FAILED_SYSCALL = ACH_STATUS_MASK(ACH_FAILED_SYSCALL),
ACH_MASK_EAGAIN = ACH_STATUS_MASK(ACH_EAGAIN),
ACH_MASK_MISSED_FRAME = ACH_STATUS_MASK(ACH_MISSED_FRAME),
ACH_MASK_TIMEOUT = ACH_STATUS_MASK(ACH_TIMEOUT),
ACH_MASK_EEXIST = ACH_STATUS_MASK(ACH_EEXIST),
ACH_MASK_ENOENT = ACH_STATUS_MASK(ACH_ENOENT),
ACH_MASK_CLOSED = ACH_STATUS_MASK(ACH_CLOSED),
ACH_MASK_BUG = ACH_STATUS_MASK(ACH_BUG),
ACH_MASK_EINVAL = ACH_STATUS_MASK(ACH_EINVAL),
ACH_MASK_CORRUPT = ACH_STATUS_MASK(ACH_CORRUPT),
ACH_MASK_BAD_HEADER = ACH_STATUS_MASK(ACH_BAD_HEADER),
ACH_MASK_EACCES = ACH_STATUS_MASK(ACH_EACCES),
ACH_MASK_CANCELED = ACH_STATUS_MASK(ACH_CANCELED),
ACH_MASK_EFAULT = ACH_STATUS_MASK(ACH_EFAULT),
ACH_MASK_EINTR = ACH_STATUS_MASK(ACH_EINTR),
ACH_MASK_ENOTSUP = ACH_STATUS_MASK(ACH_ENOTSUP),
ACH_MASK_LOCKED = ACH_STATUS_MASK(ACH_LOCKED),
ACH_MASK_NONE = 0,
ACH_MASK_ALL = 0xffffffff
};
#define ACH_MASK_STALE_FRAMES ACH_MASK_EAGAIN
#define ACH_MASK_LOCKED ACH_MASK_EAGAIN
/** Convenience typedef for enum ach_mask */
typedef enum ach_mask ach_mask_t;
/** Return the mask value for status. */
static inline int
ach_status_mask( enum ach_status status )
{
return ACH_STATUS_MASK(status);
}
/** Test if status is set in mask.
*
* \param status the status vale to check
*
* \param mask bitwise OR of enum ach_mask values
*
* \return whether the corresponding bit for status
* is set in mask
*/
static inline int
ach_status_match( enum ach_status status, int mask )
{
return (ACH_STATUS_MASK(status) & mask) ? 1 : 0;
}
/** Option flags for ach_get().
*
* Default behavior is to retrieve the oldest unseen frame without
* waiting.
*/
typedef enum {
/* default options are zero */
/** Do not block for a new messages.
*
* Exclusive with ::ACH_O_WAIT.
*/
ACH_O_NONBLOCK = 0x00,
/** Retrieve the oldest unseen message.
*
* Exclusive with ::ACH_O_LAST.
*/
ACH_O_FIRST = 0x00,
/** Timeout is an absolute time.
*
* Timeout must use the clock set during channel creation.
*
* Exclusive with ::ACH_O_RELTIME.
*
* \see ach_channel_clock()
*/
ACH_O_ABSTIME = 0x00,
/** Block until an unseen message arrives
* or timeout.
*
* If the channel already has data that this subscriber has not
* seen, ach_get() immediately copies the new data. Otherwise,
* it waits for some other process or thread to put data into the
* channel.
*
* Exclusive with ::ACH_O_NONBLOCK.
*/
ACH_O_WAIT = 0x01,
/** Read the newest message out of the channel.
*
* If the channel contains multiple messages that this subscriber
* has not seen, ach_get() will return the newest of these
* messages. The subscriber will skip past all older messages.
*
* Exclusive with ::ACH_O_FIRST.
*/
ACH_O_LAST = 0x02,
/** Copy the message out of the channel, even if already seen.
*
* The return code of ach_get() for successful copy is ACH_OK.
*/
ACH_O_COPY = 0x04,
/** Timeout is a relative time.
*
* Exclusive with ::ACH_O_ABSTIME.
*/
ACH_O_RELTIME = 0x08
} ach_get_opts_t;
/** maximum size of a channel name */
#define ACH_CHAN_NAME_MAX 64ul
/** Function type to transfer data out of the channel.
*
* This function could, for example, perform tasks such as
* de-serialization and memory allocation.
*
* \returns 0 on success, nonzero on failure
*/
typedef enum ach_status
ach_get_fun(void *cx, void **obj_dst, const void *chan_src, size_t frame_size );
/** Function type to transfer data into the channel.
*
* This function could, for example, perform tasks such as serialization.
*
* \returns 0 on success, nonzero on failure
*/
typedef enum ach_status
ach_put_fun(void *cx, void *chan_dst, const void *obj_src);
/** Struct containing 'cache' of kernel module data to avoid
* updating when no changes exist. */
typedef struct achk_opt {
int options; /**< get options used by the kernel */
struct timespec reltime; /**< kernel use relative time */
} achk_opt_t;
#ifdef CONFIG_COMPAT
/** Compat struct for achk_opt */
typedef struct achk_opt_32 {
int options; /**< get options used by the kernel */
struct compat_timespec reltime; /**< kernel use relative time */
} achk_opt_t_32;
#endif /* CONFIG_COMPAT */
#ifdef __cplusplus
}
#endif
#endif
|
63860de8e6af7deee5c1c9b5bc8a72dcda32741d
|
04c8d8da9cebc13513c1b9c7658707ecadfa0ed3
|
/Roll a Ball/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Collections_Generic_Comparer_1_gen_94.h
|
167068cab75b7494fb652b8b525711a4d9cd8bb7
|
[] |
no_license
|
fkieyhzen/RollABall
|
ed9ef9e93f3cfaecd2be10013797e97e9c1e479e
|
f083b660966094939ed2b5d2028e31bb4e86a67e
|
refs/heads/master
| 2023-03-19T18:19:11.437779 | 2015-06-08T15:27:45 | 2015-06-08T15:27:45 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 603 |
h
|
mscorlib_System_Collections_Generic_Comparer_1_gen_94.h
|
#pragma once
// System.Collections.Generic.Comparer`1<System.Collections.Generic.Dictionary`2<System.String,System.Single>>
struct Comparer_1_t7727;
// System.Object
#include "mscorlib_System_Object.h"
// System.Collections.Generic.Comparer`1<System.Collections.Generic.Dictionary`2<System.String,System.Single>>
struct Comparer_1_t7727 : public Object_t
{
};
struct Comparer_1_t7727_StaticFields{
// System.Collections.Generic.Comparer`1<T> System.Collections.Generic.Comparer`1<System.Collections.Generic.Dictionary`2<System.String,System.Single>>::_default
Comparer_1_t7727 * ____default_0;
};
|
a998ca9e5d6063e25148d497f3868191a0569df7
|
60792990ac0dc607d7c9700367105653a6de71e4
|
/mains/ft_bzero.c
|
87be15cc810854689ba586b20bf6e349735844f4
|
[] |
no_license
|
pmouhali/libft
|
7b3d8d00418d798ea786303ea1669a258827ab43
|
74de42252062945668c516da2882d1d09aad97ae
|
refs/heads/master
| 2020-08-24T18:56:11.842668 | 2020-02-23T18:53:51 | 2020-02-23T18:53:51 | 216,885,792 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 762 |
c
|
ft_bzero.c
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
void ft_bzero(void *s, size_t n);
void print_itab(int *tab, int size)
{
int i;
i = 0;
while (i < size)
{
printf("%d | ", tab[i]);
i++;
}
printf("\n");
}
int main(void)
{
char new[10];
int tab[10];
char new2[10];
int tab2[10];
bzero(new, 9);
new[9] = 0;
printf("new : %s\n", new);
bzero(new, 2);
new[9] = 0;
printf("new : %s\n", new);
bzero(tab, 10*sizeof(int));
print_itab(tab, 10);
bzero(tab, 37);
print_itab(tab, 10);
ft_bzero(new2, 9);
new2[9] = 0;
printf("new2: %s\n", new2);
ft_bzero(new2, 2);
new2[9] = 0;
printf("new2: %s\n", new2);
ft_bzero(tab2, 10*sizeof(int));
print_itab(tab2, 10);
ft_bzero(tab2, 37);
print_itab(tab2, 10);
}
|
d0c1f14e4780e80db382dd1e6f9a2a8080f61286
|
4df3bbdff7bc533ad8971b39f0787f72ea62b503
|
/firmware_wchat/drivers/fiforx.c
|
2d7cd4c1a667c9070becfc39206455fdfbd3e6e5
|
[] |
no_license
|
sensendedipan/wchat_mqtt
|
72dfd7601fcbe30652c5d4bc7b3f01cbc322e494
|
91c56b1c4bcbd4ee4902a9256501f503abd646a4
|
refs/heads/master
| 2020-03-25T22:21:27.296259 | 2018-09-05T07:50:15 | 2018-09-05T07:50:15 | 144,218,548 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,827 |
c
|
fiforx.c
|
#include "fiforx.h"
#include "board.h"
static uint8_t buf_flags;
static uint8_t buffer[FIFO_RX_BUF_SIZE];
static uint16_t in_index, out_index;
/**
* @brief Write n data to buffer
* @retval None
*/
uint16_t fifoRxPushBuf(uint8_t* data, uint16_t n)
{
uint16_t i = 0;
uint16_t data_count = 0;
while (n--) {
if (buf_flags & OVREFLOW_FLAG_RX2) {
return 0;
} else {
buffer[in_index++] = data[i++];
in_index &= FIFO_RX_BUF_MASK;
buf_flags &= ~EMPTY_FLAG_RX2;
data_count++;
if (in_index == out_index) {
buf_flags |= OVREFLOW_FLAG_RX2;
}
}
}
return data_count;
}
/**
* @brief Flush buffer
* @retval None
*/
void fifoRxFlushBuf(void)
{
out_index = in_index;
buf_flags |= EMPTY_FLAG_RX2;
}
/**
* @brief Read n data from buffer
* @retval None
*/
uint16_t fifoRxPopBuf(uint8_t* out_buf, uint16_t n)
{
uint16_t i = 0;
uint16_t data_count = 0;
while (n--) {
if (out_index == in_index) {
if (!(buf_flags & OVREFLOW_FLAG_RX2)) {
buf_flags |= EMPTY_FLAG_RX2;
return 0;
}
}
out_buf[i++] = buffer[out_index++];
out_index &= FIFO_RX_BUF_MASK;
data_count++;
buf_flags &= ~OVREFLOW_FLAG_RX2;
}
return data_count;
}
/**
* @brief Get unread data count in buffer
* @retval None
*/
uint16_t fifoRxGetBufDataCount(void)
{
if (out_index == in_index) {
if (!(buf_flags & OVREFLOW_FLAG_RX2)) {
buf_flags |= EMPTY_FLAG_RX2;
return 0;
} else {
return FIFO_RX_BUF_SIZE;
}
}
if (in_index > out_index) {
return in_index - out_index;
} else {
return FIFO_RX_BUF_SIZE - out_index + in_index;
}
}
/**
* @brief Look data in buffer, but not read out
* @retval None
*/
void fifoRxLookBuf(uint8_t* out_buf)
{
uint16_t i = 0;
while (i < FIFO_RX_BUF_SIZE) {
out_buf[i] = buffer[i];
i++;
}
}
|
38aa808e8fb431030a414417f09b1cc24d1f1a52
|
d000aff18cf46a5b51584bbc88c481933de7e454
|
/proyect0/exercise5.18withPunteros.c
|
b6f7d549d1ce6bde654df3d2a0a13e8f0900d827
|
[] |
no_license
|
AdanUrbanReyes/operatingSystems
|
5107b880548d8f4d357a6a12e53202c3a3d255d2
|
965877f70bfd9d9c8b0118655466a1ab80117d9c
|
refs/heads/master
| 2021-01-13T00:44:51.187202 | 2016-02-13T03:24:24 | 2016-02-13T03:24:24 | 51,630,256 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 860 |
c
|
exercise5.18withPunteros.c
|
#include <stdio.h>
#include <stdlib.h>//for use functions realloc
#include <string.h>
char even(int *number){
if(!(*number%2))
return 1;
return 0;
}
int main(){
int *numbers,*i,*numbersEntered;
i=(int*)malloc(sizeof(int));
numbersEntered=(int*)malloc(sizeof(int));
*numbersEntered=1;
char *option=(char *)malloc(sizeof(char)*3);
do{
printf("would you like insert other brute sale? yes/not\n");
scanf("%s",option);
if(strncasecmp(option,"y",1))
continue;
numbers=(int*)realloc(numbers,sizeof(int)*(*numbersEntered));
printf("enter number\n");
scanf("%d",(numbers+*numbersEntered-1));
*numbersEntered=*numbersEntered+1;
}while(strncasecmp(option,"n",1));
for(*i=0;*i<(*numbersEntered)-1;*i=*i+1){
if(even((numbers+(*i))))
printf("%d is par\n",*(numbers+(*i)));
else
printf("%d is impar\n",*(numbers+(*i)));
}
return 0;
}
|
c00e83184e55800e6e271286fb33b024011fccee
|
607d320afc2328b4d6ae95d2802519473e4e2c9b
|
/19.3 - 存取陣列外元素的問題/19.3.c
|
4d7b3fff2d070d8167008c481941e32759995aea
|
[] |
no_license
|
FeisStudio/C-language-Feis-Studio
|
75ae2df4f8addd8cf90cf41307fbc97d8d6ecede
|
41adf964cb244e8045ad8de3b91f6f22a12368ef
|
refs/heads/master
| 2021-02-10T17:48:21.477638 | 2020-07-28T14:03:15 | 2020-07-28T14:03:15 | 244,405,360 | 2 | 1 | null | null | null | null |
GB18030
|
C
| false | false | 847 |
c
|
19.3.c
|
#include<stdio.h>
int max5(int[5]);
//int max3(int[3]);
//int main() {
// int v[3] = { 1,2,3 };
// printf("%d\n", v[0]);
// printf("%d\n", v[1]);
// printf("%d\n", v[3/2]); //v[1]
//
// printf("%d\n", v[0.5]); //編譯錯誤
// printf("%d\n", v[3 / 2.]);//編譯錯誤
//
// printf("%d\n", v[3]); //未定義行爲
// printf("%d\n", v[4]); //未定義行爲
// printf("%d\n", v[-1]); //未定義行爲
//
// return 0;
//}
int main() {
int a[3] = { 3,9,7 };
printf("Max: %d\n", max5(a));
int b[5] = { 3,2,1,9,7 };
printf("Max: %d\n", max5(b));
return 0;
}
//int max5(int v[5]) {
// int max = v[0], i;
// for (i = 1; i < 5; i++) {
// if (v[i] > max) {
// max = v[i];
// }
// }
// return max;
//}
int max5(int v[5]) {
int max = v[0], i;
for (i = 1; i < 5; i++) {
if (v[i] > max) {
max = v[i];
}
}
return max;
}
|
90ec25f97769751493966569b8755f1f7fc0e333
|
62269aec870b7aef4b480a6518473c878501fb0c
|
/Book3rdEdition/code/chapter_16/ccs/AMrx/AMreceiver_ISRs.c
|
e1eab85316fdf3db8472748d6314667048357662
|
[] |
no_license
|
ADA2293/ECE303
|
c48d92970945dd1870d3148f577dc1b67bf9b82c
|
af154f908150c1c5e23a788848c4c02de96c4c3d
|
refs/heads/master
| 2022-02-23T11:13:21.861254 | 2019-10-31T18:44:39 | 2019-10-31T18:44:39 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,637 |
c
|
AMreceiver_ISRs.c
|
// Welch, Wright, & Morrow,
// Real-time Digital Signal Processing, 2017
///////////////////////////////////////////////////////////////////////
// Filename: AMreceiver_ISRs.c
//
// Synopsis: Interrupt service routine for codec data transmit/receive
//
///////////////////////////////////////////////////////////////////////
#include "DSP_Config.h"
#include "coeff.h"
#include <math.h>
// Data is received as 2 16-bit words (left/right) packed into one
// 32-bit word. The union allows the data to be accessed as a single
// entity when transferring to and from the serial port, but still be
// able to manipulate the left and right channels independently.
#define LEFT 0
#define RIGHT 1
volatile union {
Uint32 UINT;
Int16 Channel[2];
} CodecDataIn, CodecDataOut;
/* add any global variables here */
float x[N]; // received AM signal values
float y; // Hilbert Transforming (HT) filter's output
float envelope[2]; // real envelope
float output[2] = {0,0}; // output of the D.C. blocking filter
float r = 0.99; // pole location for the D.C. blocking filter
Int32 i; // integer index
interrupt void Codec_ISR()
///////////////////////////////////////////////////////////////////////
// Purpose: Codec interface interrupt service routine
//
// Input: None
//
// Returns: Nothing
//
// Calls: CheckForOverrun, ReadCodecData, WriteCodecData
//
// Notes: None
///////////////////////////////////////////////////////////////////////
{
/* add any local variables here */
if(CheckForOverrun()) // overrun error occurred (i.e. halted DSP)
return; // so serial port is reset to recover
CodecDataIn.UINT = ReadCodecData(); // get input data samples
/* add your code starting here */
/* algorithm begins here */
x[0] = CodecDataIn.Channel[RIGHT];// current AM signal value
y = 0; // initialize the filter's output value
for (i = 0; i < N; i++) {
y += x[i]*B[i]; // perform the HT (dot-product)
}
envelope[0] = sqrtf(y*y + x[16]*x[16]); // real envelope
/* implement the D.C. blocking filter */
output[0] = r*output[1] + (float)0.5 * (r + 1)*(envelope[0] - envelope[1]);
for (i = N-1; i > 0; i--) {
x[i] = x[i-1]; // setup for the next input
}
envelope[1] = envelope[0]; // setup for the next input
output[1] = output[0]; // setup for the next input
CodecDataOut.Channel[ LEFT] = output[0]; // setup the LEFT value
CodecDataOut.Channel[RIGHT] = output[0]; // setup the RIGHT value
/* algorithm ends here */
/* end your code here */
WriteCodecData(CodecDataOut.UINT); // send output data to port
}
|
ed103bebcee176f8b2a1422a46bd8fb69ba2c8a7
|
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
|
/source/linux/drivers/net/ethernet/freescale/extr_gianfar.c_cluster_entry_per_class.c
|
e62710c5d572ee5823ab6cf9a160699dd810937f
|
[] |
no_license
|
isabella232/AnghaBench
|
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
|
9a5f60cdc907a0475090eef45e5be43392c25132
|
refs/heads/master
| 2023-04-20T09:05:33.024569 | 2021-05-07T18:36:26 | 2021-05-07T18:36:26 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,647 |
c
|
extr_gianfar.c_cluster_entry_per_class.c
|
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef size_t u32 ;
struct gfar_private {size_t* ftp_rqfpr; size_t* ftp_rqfcr; } ;
/* Variables and functions */
size_t FPR_FILER_MASK ;
size_t RQFCR_AND ;
size_t RQFCR_CLE ;
size_t RQFCR_CMP_EXACT ;
size_t RQFCR_CMP_NOMATCH ;
size_t RQFCR_PID_MASK ;
size_t RQFCR_PID_PARSE ;
int /*<<< orphan*/ gfar_write_filer (struct gfar_private*,size_t,size_t,size_t) ;
__attribute__((used)) static u32 cluster_entry_per_class(struct gfar_private *priv, u32 rqfar,
u32 class)
{
u32 rqfpr = FPR_FILER_MASK;
u32 rqfcr = 0x0;
rqfar--;
rqfcr = RQFCR_CLE | RQFCR_PID_MASK | RQFCR_CMP_EXACT;
priv->ftp_rqfpr[rqfar] = rqfpr;
priv->ftp_rqfcr[rqfar] = rqfcr;
gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
rqfar--;
rqfcr = RQFCR_CMP_NOMATCH;
priv->ftp_rqfpr[rqfar] = rqfpr;
priv->ftp_rqfcr[rqfar] = rqfcr;
gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
rqfar--;
rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_PARSE | RQFCR_CLE | RQFCR_AND;
rqfpr = class;
priv->ftp_rqfcr[rqfar] = rqfcr;
priv->ftp_rqfpr[rqfar] = rqfpr;
gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
rqfar--;
rqfcr = RQFCR_CMP_EXACT | RQFCR_PID_MASK | RQFCR_AND;
rqfpr = class;
priv->ftp_rqfcr[rqfar] = rqfcr;
priv->ftp_rqfpr[rqfar] = rqfpr;
gfar_write_filer(priv, rqfar, rqfcr, rqfpr);
return rqfar;
}
|
1e227dd6530ad4a44b5f3b49f6035ff9086731a1
|
e1be0f6b77f1c23d9a8a38a32458d22964056a71
|
/hw1/src/main.c
|
4d920f732d3143d05875caa7af24f68f7ee6d6de
|
[] |
no_license
|
chenk97/C-language-code
|
51cb139c12e9f686d99a341ecb7f0988707791d9
|
c807aa3f77d7a89a7ff727a0c5f0c375fa2f73a4
|
refs/heads/master
| 2022-06-20T05:14:00.218119 | 2020-05-07T03:00:01 | 2020-05-07T03:00:01 | 261,934,688 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,892 |
c
|
main.c
|
#include <stdio.h>
#include <stdlib.h>
#include "const.h"
#include "debug.h"
#ifdef _STRING_H
#error "Do not #include <string.h>. You will get a ZERO."
#endif
#ifdef _STRINGS_H
#error "Do not #include <strings.h>. You will get a ZERO."
#endif
#ifdef _CTYPE_H
#error "Do not #include <ctype.h>. You will get a ZERO."
#endif
int main(int argc, char **argv)
{
// path_init("hello");
// debug("%s",path_buf);
// path_push("world");
// path_push("hahaha");
// path_pop();
// debug("length after pop %d", path_length);
// debug("%s",path_buf);
// path_pop();
// debug("length after 2nd pop %d", path_length);
// debug("%s",path_buf);
/********************/
// mode_t mode =0;
// mode|=0x000041ed;
// if(S_ISDIR(mode)){
// debug("dirrrrrrrrrrrrr");
// }
// int dir_result = mkdir("rsrc/test_outt", 0700);
// if(dir_result != 0){
// //errors here
// debug("**********************error************************");
// }
// else{
// //your code here
// debug("***************hello*****************");
// }
int ret;
if(validargs(argc, argv))
USAGE(*argv, EXIT_FAILURE);
debug("Options: 0x%x", global_options);
if(global_options & 1)//return flase unless global_option = 1 whihc indicates -h
USAGE(*argv, EXIT_SUCCESS);//print help menu
if(global_options == 2){//-p /tmp will be the DIR to serialize
debug("serialization");
if(serialize()){return EXIT_FAILURE;}
//return EXIT_SUCCESS;
}
if(global_options == 4 || global_options ==12){//p /tmp will be the DIR to deserialize
debug("deserialization");
if(deserialize()){return EXIT_FAILURE;}
//return EXIT_SUCCESS;
}
return EXIT_SUCCESS;
}
/*
* Just a reminder: All non-main functions should
* be in another file not named main.c
*/
|
565d95bd36bc93b882ae0b83ab3bd48ff7c5ad71
|
3413cd5d29554acf4bcec833d2fcebf40304625a
|
/srcs/render_floor_and_ceil.c
|
6829232579b0b52431853bc3ed449f0f084249ed
|
[] |
no_license
|
z-iz/42_cub3d
|
6e5121b3742befd65e2773d64fdf156bafd48215
|
bd9d527ff572bd2cec3c02206fbd2bc59e77258b
|
refs/heads/main
| 2023-04-06T15:11:26.995670 | 2020-11-24T19:57:12 | 2020-11-24T19:57:12 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 3,405 |
c
|
render_floor_and_ceil.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* render_floor_and_ceil.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: larosale <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/08/12 01:20:32 by larosale #+# #+# */
/* Updated: 2020/08/21 01:47:59 by larosale ### ########.fr */
/* */
/* ************************************************************************** */
#include "engine.h"
/*
** Calculates necessary values for texturing floor and ceiling, fills
** them to the "ft" structure.
*/
static void calc_render_floor_and_ceil(int y, t_ftex *ft, t_all *a)
{
ft->ray_dir_x0 = a->m->dir_x - a->m->plane_x;
ft->ray_dir_y0 = a->m->dir_y - a->m->plane_y;
ft->ray_dir_x1 = a->m->dir_x + a->m->plane_x;
ft->ray_dir_y1 = a->m->dir_y + a->m->plane_y;
ft->p = y - a->w->win_height / 2;
ft->pos_z = 0.5 * a->w->win_height;
ft->row_distance = ft->pos_z / ft->p;
ft->floor_step_x = ft->row_distance * (ft->ray_dir_x1 - ft->ray_dir_x0) /
a->w->win_width;
ft->floor_step_y = ft->row_distance * (ft->ray_dir_y1 - ft->ray_dir_y0) /
a->w->win_width;
ft->floor_x = a->m->pos_x + ft->row_distance * ft->ray_dir_x0;
ft->floor_y = a->m->pos_y + ft->row_distance * ft->ray_dir_y0;
return ;
}
/*
** If textures for floor and/or ceiling are defined, draws horizontal
** texturized floor (ceiling) line, corresponding to the vertical
** screen coordinate y.
*/
static void draw_line(int x, int y, t_ftex *ft, t_all *a)
{
unsigned int color;
color = 0;
if (a->tf)
{
ft->ftex_x = (int)(a->tf->img_width * (ft->floor_x - ft->cell_x)) &
(a->tf->img_width - 1);
ft->ftex_y = (int)(a->tf->img_height * (ft->floor_y - ft->cell_y)) &
(a->tf->img_height - 1);
color = *(unsigned int *)(a->tf->img_addr + ft->ftex_y *
a->tf->img_line_size + ft->ftex_x * a->tf->img_bpp / 8);
a->m->shading ? color_shading(&color, ft->row_distance) : 0;
pixel_put(a->i, x, y, color);
}
if (a->tc)
{
ft->ctex_x = (int)(a->tc->img_width * (ft->floor_x - ft->cell_x)) &
(a->tc->img_width - 1);
ft->ctex_y = (int)(a->tc->img_height * (ft->floor_y - ft->cell_y)) &
(a->tc->img_height - 1);
color = *(unsigned int *)(a->tc->img_addr + ft->ctex_y *
a->tc->img_line_size + ft->ctex_x * a->tc->img_bpp / 8);
a->m->shading ? color_shading(&color, ft->row_distance) : 0;
pixel_put(a->i, x, a->w->win_height - y - 1, color);
}
}
/*
** Renders the horizontal texturized line of floor and ceiling, if the
** respective textures are defined for every vertical screen pixel "y".
*/
void render_floor_and_ceil(int y, t_ftex *ft, t_all *a)
{
int x;
x = 0;
if (!(a->tf) && !(a->tc))
return ;
clear_ftex(ft);
calc_render_floor_and_ceil(y, ft, a);
while (x < a->w->win_width)
{
ft->cell_x = (int)(ft->floor_x);
ft->cell_y = (int)(ft->floor_y);
draw_line(x, y, ft, a);
ft->floor_x += ft->floor_step_x;
ft->floor_y += ft->floor_step_y;
x++;
}
return ;
}
|
58ff4d324b65d1a7685f2f4b4e273fb456b4b946
|
0afc79b2146dc174df72ad307cc02acba730a9eb
|
/nRF52_DFU_V1.1.6_beta/Sources/algorithm/SkippingAlg.c
|
f3dd007e3e1f6f099b52247014114182a61e36df
|
[] |
no_license
|
chendetao/HB044
|
4a0c1b714746bac0e9299104bfa92a712fe51221
|
5da616d7617300b14d342e988e8db9ede948e778
|
refs/heads/master
| 2020-03-21T12:44:07.530020 | 2018-06-25T08:58:48 | 2018-06-25T08:58:48 | 138,569,157 | 0 | 3 | null | null | null | null |
UTF-8
|
C
| false | false | 11,040 |
c
|
SkippingAlg.c
|
#include "SkippingAlg.h"
struct accelDevice accel;
unsigned int skip_mTicks = 0;
////////////////////////////////////////////////////////////////////////////////
#define FILTER_NR 9
static int filter_arr[3][FILTER_NR];
/**
* func void accel_filter_init(void);
* To init the filter array.
*/
static void accel_filter_init(void)
{
for ( int i = 0; i < 2; i++ )
{
for ( int j = 0; j < FILTER_NR; j++ )
{
filter_arr[i][j] = 0;
}
}
}
static int accel_filter_( int idx, int value )
{
int sum = 0;
for ( int i = 0; i < FILTER_NR-1; i++ )
{
filter_arr[idx][i] = filter_arr[idx][i+1];
sum += filter_arr[idx][i+1];
}
filter_arr[idx][FILTER_NR-1] = value;
sum += value;
return sum / FILTER_NR;
}
////////////////////////////////////////////////////////////////////////////
// //
// //
////////////////////////////////////////////////////////////////////////////
static int X[3];
int bMax_X[3];
int bMin_X[3];
int xh_flag = 0, xl_flag = 0;
int fx_max = 0;
unsigned int ProcessX( int value )
{
int n = value;
X[0] = X[1];
X[1] = X[2];
X[2] = n;
if ( n > accel.vMax_X )
{
accel.vMax_X = n; accel.max_c_x = 0;
}
if ( n < accel.vMax_X )
{
accel.max_c_x++;
if ( (accel.max_c_x >= 2) && (xh_flag == 0)
&& (X[0] > X[1]) && (X[1] > X[2]) ) // find highest point
{
accel.max_c_x = 0;
bMax_X[0] = bMax_X[1];
bMax_X[1] = bMax_X[2];
bMax_X[2] = accel.vMax_X;
accel.aMax[0] = (bMax_X[0]+bMax_X[1]+bMax_X[2])/3;
accel.max_x_tick = skip_mTicks;
xh_flag = 1; xl_flag = 0;
accel.vMax_X = 0;
accel.hightCnt[0]++;
}
}
if ( n < accel.vMin_X )
{
accel.vMin_X = n; accel.min_c_x = 0;
}
if ( n > accel.vMin_X )
{
accel.min_c_x++;
if ( (accel.min_c_x >= 2) && (xl_flag == 0)
&& (X[0] < X[1]) && (X[1] < X[2])) // find lowest point
{
accel.min_c_x = 0;
bMin_X[0] = bMin_X[1];
bMin_X[1] = bMin_X[2];
bMin_X[2] = accel.vMin_X;
accel.aMin[0] = (bMin_X[0]+bMin_X[1]+bMin_X[2])/3;
xl_flag = 1; xh_flag = 0;
accel.vMin_X = 2047;
accel.lowCnt[0]++;
}
}
{
if ( (accel.aMax[0] > accel.aMin[0]) && !(skip_mTicks % 50)) // update The extreme array
{
for ( int i = 0; i < 3; i++ )
{
bMax_X[i] -= 1;
}
accel.aMax[0] = (bMax_X[0]+bMax_X[1]+bMax_X[2])/3;
}
if ( (accel.aMin[0] < accel.aMax[0]) && !(skip_mTicks % 50) )
{
for ( int i = 0; i < 3; i++ )
{
bMin_X[i] += 1;
}
accel.aMin[0] = (bMin_X[0]+bMin_X[1]+bMin_X[2])/3;
}
}
{
int diff = accel.aMax[0] - accel.aMin[0];
int bl = (accel.aMax[0]+accel.aMin[0])/2;
if ( (diff > 35 ) && (n >bl ) && (fx_max == 0) )
{
fx_max = 1;
if ( ( (skip_mTicks -accel.min_x_tick ) > 150) && ((skip_mTicks - accel.min_x_tick) < 2100) )
{
accel.c[0]++;
accel.ic[0]++;
int max = (accel.ic[1] > accel.ic[2])?(accel.ic[1]):(accel.ic[2]);
if ( accel.ic[0] < max )
{
accel.ic[0] = max;
accel.aCounter = max;
} else {
accel.aCounter = accel.ic[0];
}
}
accel.min_x_tick = skip_mTicks;
}
}
if ( (n < ((accel.aMin[0] + accel.aMax[0])/2 )) && (fx_max == 1 ) )
{
fx_max = 0;
}
return 0;
}
static int Y[3];
int bMax_Y[3];
int bMin_Y[3];
int yh_flag = 0, yl_flag = 0;
int fy_max = 0;
unsigned int ProcessY( int value )
{
int n = value;
Y[0] = Y[1];
Y[1] = Y[2];
Y[2] = n;
if ( n > accel.vMax_Y )
{
accel.vMax_Y = n; accel.max_c_y = 0;
}
if ( n < accel.vMax_Y )
{
accel.max_c_y++;
if ( (accel.max_c_y >= 2) && (yh_flag == 0)
&& (Y[0] > Y[1]) && (Y[1] > Y[2]) ) // find highest point
{
accel.max_c_y = 0;
bMax_Y[0] = bMax_Y[1];
bMax_Y[1] = bMax_Y[2];
bMax_Y[2] = accel.vMax_Y;
accel.aMax[1] = (bMax_Y[0]+bMax_Y[1]+bMax_Y[2])/3;
accel.max_y_tick = skip_mTicks;
yh_flag = 1; yl_flag = 0;
accel.vMax_Y = 0;
accel.hightCnt[1]++;
}
}
if ( n < accel.vMin_Y )
{
accel.vMin_Y = n; accel.min_c_y = 0;
}
if ( n > accel.vMin_Y )
{
accel.min_c_y++;
if ( (accel.min_c_y >= 2) && (yl_flag == 0)
&& (Y[0] < Y[1]) && (Y[1] < Y[2])) // find lowest point
{
accel.min_c_y = 0;
bMin_Y[0] = bMin_Y[1];
bMin_Y[1] = bMin_Y[2];
bMin_Y[2] = accel.vMin_Y;
accel.aMin[1] = (bMin_Y[0]+bMin_Y[1]+bMin_Y[2])/3;
yl_flag = 1; yh_flag = 0;
accel.vMin_Y = 2047;
accel.lowCnt[1]++;
}
}
{
if ( (accel.aMax[1] > accel.aMin[1]) && !(skip_mTicks % 50) ) // update The extreme array
{
for ( int i = 0; i < 3; i++ )
{
bMax_Y[i] -= 1;
}
accel.aMax[1] = (bMax_Y[0]+bMax_Y[1]+bMax_Y[2])/3;
}
if ( (accel.aMin[1] < accel.aMax[1]) && !(skip_mTicks % 50) )
{
for ( int i = 0; i < 3; i++ )
{
bMin_Y[i] += 1;
}
accel.aMin[1] = (bMin_Y[0]+bMin_Y[1]+bMin_Y[2])/3;
}
}
{
int diff = accel.aMax[1] - accel.aMin[1];
int bl = (accel.aMax[1]+accel.aMin[1])/2;
if ( (diff > 35 ) && (n >bl ) && (fy_max == 0) )
{
fy_max = 1;
if ( ( (skip_mTicks -accel.min_y_tick ) > 150) && ((skip_mTicks - accel.min_y_tick) < 2100) )
{
accel.c[1]++;
accel.ic[1]++;
int max = (accel.ic[0] > accel.ic[2])?(accel.ic[0]):(accel.ic[2]);
if ( accel.ic[1] < max )
{
accel.ic[1] = max;
accel.aCounter = max;
} else {
accel.aCounter = accel.ic[1];
}
}
accel.min_y_tick = skip_mTicks;
}
}
if ( (n < ((accel.aMin[1] + accel.aMax[1])/2 )) && (fy_max == 1 ) )
{
fy_max = 0;
}
return 0;
}
static int Z[3];
int bMax_Z[3];
int bMin_Z[3];
int zh_flag = 0, zl_flag = 0;
int fz_max = 0;
unsigned int ProcessZ( int value )
{
int n = value;
Z[0] = Z[1];
Z[1] = Z[2];
Z[2] = n;
if ( n > accel.vMax_Z )
{
accel.vMax_Z = n; accel.max_c_z = 0;
}
if ( n < accel.vMax_Z )
{
accel.max_c_z++;
if ( (accel.max_c_z >= 2) && (zh_flag == 0)
&& (Z[0] > Z[1]) && (Z[1] > Z[2]) ) // find highest point
{
accel.max_c_z = 0;
bMax_Z[0] = bMax_Z[1];
bMax_Z[1] = bMax_Z[2];
bMax_Z[2] = accel.vMax_Z;
accel.aMax[2] = (bMax_Z[0]+bMax_Z[1]+bMax_Z[2])/3;
accel.max_z_tick = skip_mTicks;
zh_flag = 1; zl_flag = 0;
accel.vMax_Z = 0;
accel.hightCnt[2]++;
}
}
if ( n < accel.vMin_Z )
{
accel.vMin_Z = n; accel.min_c_z = 0;
}
if ( n > accel.vMin_Z )
{
accel.min_c_z++;
if ( (accel.min_c_z >= 2) && (zl_flag == 0)
&& (Z[0] < Z[1]) && (Z[1] < Z[2])) // find lowest point
{
accel.min_c_z = 0;
bMin_Z[0] = bMin_Z[2];
bMin_Z[1] = bMin_Z[2];
bMin_Z[2] = accel.vMin_Z;
accel.aMin[2] = (bMin_Z[0]+bMin_Z[1]+bMin_Z[2])/3;
zl_flag = 1; zh_flag = 0;
accel.vMin_Z = 2047;
accel.lowCnt[2]++;
}
}
{
if ( (accel.aMax[2] > accel.aMin[2]) && !(skip_mTicks % 50) ) // update The extreme array
{
for ( int i = 0; i < 3; i++ )
{
bMax_Z[i] -= 1;
}
accel.aMax[2] = (bMax_Z[0]+bMax_Z[1]+bMax_Z[2])/3;
}
if ( (accel.aMin[2] < accel.aMax[2]) && !(skip_mTicks % 50) )
{
for ( int i = 0; i < 3; i++ )
{
bMin_Z[i] += 1;
}
accel.aMin[2] = (bMin_Z[0]+bMin_Z[1]+bMin_Z[2])/3;
}
}
{
int diff = accel.aMax[2] - accel.aMin[2];
int bl = (accel.aMax[2]+accel.aMin[2])/2;
if ( (diff > 35 ) && (n >bl ) && (fz_max == 0) )
{
fz_max = 1;
if ( ( (skip_mTicks -accel.min_z_tick ) > 150) && ((skip_mTicks - accel.min_z_tick) < 2100) )
{
accel.c[2]++;
accel.ic[2]++;
int max = (accel.ic[0] > accel.ic[1])?(accel.ic[0]):(accel.ic[1]);
if ( accel.ic[2] < max )
{
accel.ic[2] = max;
accel.aCounter = max;
} else {
accel.aCounter = accel.ic[2];
}
}
accel.min_z_tick = skip_mTicks;
}
}
if ( (n < ((accel.aMin[2] + accel.aMax[2])/2 )) && (fz_max == 1 ) )
{
fz_max = 0;
}
return 0;
}
#if 0
static int LV[3];
static int LT[3];
static float kl[3];
float get_k(int idx, int v)
{
float k = (float)(v-LV[idx])/(skip_mTicks-LT[idx]);
float k2 = (k-kl[idx])/(skip_mTicks-LT[idx]);
LV[idx] = v;
LT[idx] = skip_mTicks;
return k;
}
#endif
void Alogrithm_Cal(int x, int y, int z)
{
ProcessX(x);
ProcessY(y);
ProcessZ(z);
}
unsigned int stepFlagmTicks_1 = 0;
unsigned int stepFlagmTicks_2 = 0;
unsigned char clear_flag = 0;
void Alogrithm_Do_Process(int x, int y, int z)
{
if ( accel.step_Machine == STEP_MACHINE_WAIT )
{
// 状态机为0:检测步数是否 >= 5
if ( accel.aCounter - accel.lCounter >= 5 )
{
// 状态机切换到1
accel.step_Machine = STEP_MACHINE_PROC;
stepFlagmTicks_2 = skip_mTicks;
}else
if ( accel.temp_counter != accel.aCounter )
{
// 步数小于5,但不等于上次记录的值
// 更新临时变量,记录T1
accel.temp_counter = accel.aCounter;
stepFlagmTicks_1 = skip_mTicks;
}
}else{
// 状态机为1:步数不等于上次的值
if ( accel.lCounter != accel.aCounter )
{
// 更新步数,记录时间T2
accel.lCounter = accel.aCounter;
stepFlagmTicks_2 = skip_mTicks;
}
}
if ( accel.step_Machine == STEP_MACHINE_WAIT )
{
if ( (skip_mTicks - stepFlagmTicks_1) > 2200 )
{
clear_flag = 0x1;
}
}else{
if ( (skip_mTicks - stepFlagmTicks_2) > 2200 )
{
clear_flag = 0x1;
}
}
if ( clear_flag & 0x1 )
{
// T1 大于2.2秒,无效,临时累计的步数需要消除
// T2 大于2.2秒,无效,临时累计的步数需要消除
int temp_counter = accel.lCounter;
accel.aCounter = temp_counter;
for ( int i = 0; i < 3; i++ )
{
accel.c[i] = temp_counter;
accel.ic[i] = temp_counter;
}
// 状态机回0
accel.step_Machine = STEP_MACHINE_WAIT;
stepFlagmTicks_1 = stepFlagmTicks_2 = skip_mTicks;
clear_flag = 0x0;
}
}
void Alogrithm_Process( int x, int y, int z)
{
/** 滤波处理 */
x = accel_filter_(0, x);
y = accel_filter_(1, y);
z = accel_filter_(2, z);
/** 算法处理 */
Alogrithm_Cal(x, y, z);
/** 状态处理 */
Alogrithm_Do_Process(x,y,z);
/** 更新时基计数器 */
skip_mTicks += 25;
/** 计算一阶导数和二阶导数 */
#if 0
accel.k[0] = get_k(0,x);
accel.k[1] = get_k(1,y);
accel.k[2] = get_k(2,z);
#endif
}
#include <string.h>
void Alogrithm_Init(void)
{
/** 算法初始化 */
memset(&accel, 0, sizeof(accel));
accel_filter_init();
accel.vMin_X = 2047;
for ( int i = 0; i < 3; i++ )
{
bMin_X[i] = 2047;
accel.aMin[i] = 2047;
}
accel.step_Machine = STEP_MACHINE_WAIT;
}
|
a2395c7962519d7fe962417baed901484cd55367
|
473fc28d466ddbe9758ca49c7d4fb42e7d82586e
|
/app/src/main/java/com/syd/source/aosp/external/strace/xlat/membarrier_cmds.h
|
9d4d5187228b3dfd6171781e78fab38375a34b3a
|
[
"BSD-3-Clause"
] |
permissive
|
lz-purple/Source
|
a7788070623f2965a8caa3264778f48d17372bab
|
e2745b756317aac3c7a27a4c10bdfe0921a82a1c
|
refs/heads/master
| 2020-12-23T17:03:12.412572 | 2020-01-31T01:54:37 | 2020-01-31T01:54:37 | 237,205,127 | 4 | 2 | null | null | null | null |
UTF-8
|
C
| false | false | 624 |
h
|
membarrier_cmds.h
|
/* Generated by ./xlat/gen.sh from ./xlat/membarrier_cmds.in; do not edit. */
#if !(defined(MEMBARRIER_CMD_QUERY) || (defined(HAVE_DECL_MEMBARRIER_CMD_QUERY) && HAVE_DECL_MEMBARRIER_CMD_QUERY))
# define MEMBARRIER_CMD_QUERY 0
#endif
#if !(defined(MEMBARRIER_CMD_SHARED) || (defined(HAVE_DECL_MEMBARRIER_CMD_SHARED) && HAVE_DECL_MEMBARRIER_CMD_SHARED))
# define MEMBARRIER_CMD_SHARED 1
#endif
#ifdef IN_MPERS
# error static const struct xlat membarrier_cmds in mpers mode
#else
static
const struct xlat membarrier_cmds[] = {
XLAT(MEMBARRIER_CMD_QUERY),
XLAT(MEMBARRIER_CMD_SHARED),
XLAT_END
};
#endif /* !IN_MPERS */
|
b75ea6cb225cfed1b0b64b804ab833e4a4509a2b
|
af9eabdb2ac240f9f2a2f3e92e6bc9044069362e
|
/sdk/projects/examples/driver/gpio/example_gpio.c
|
e0aa147189a6c2feed130c04b08b5959c96f82f1
|
[
"MIT"
] |
permissive
|
T-head-Semi/wujian100_open
|
9926f118867a08283004759d09af6631db2e92cf
|
83e297583bb3454b688f9f27d6bc20ff3276ad32
|
refs/heads/master
| 2022-07-27T05:13:57.608880 | 2021-12-31T09:23:38 | 2021-12-31T09:23:38 | 216,210,370 | 1,846 | 609 |
MIT
| 2019-12-15T10:41:08 | 2019-10-19T13:25:30 |
Verilog
|
UTF-8
|
C
| false | false | 1,684 |
c
|
example_gpio.c
|
/*
* Copyright (C) 2017-2019 Alibaba Group Holding Limited
*/
/******************************************************************************
* @file example_gpio.c
* @brief the main function for the GPIO driver
* @version V1.0
* @date 02. June 2017
******************************************************************************/
#include <stdio.h>
#include "soc.h"
#include "drv_gpio.h"
#include "pin_name.h"
#include "pin.h"
volatile static bool int_flag = 1;
static void gpio_interrupt_handler(int32_t idx)
{
int_flag = 0;
}
void example_pin_gpio_init(void)
{
drv_pinmux_config(EXAMPLE_GPIO_PIN, EXAMPLE_GPIO_PIN_FUNC);
}
void gpio_falling_edge_interrupt(pin_name_e gpio_pin)
{
gpio_pin_handle_t pin = NULL;
example_pin_gpio_init();
printf("please change the gpio pin %s from high to low\r\n", EXAMPLE_BOARD_GPIO_PIN_NAME);
pin = csi_gpio_pin_initialize(gpio_pin, gpio_interrupt_handler);
csi_gpio_pin_config_mode(pin, GPIO_MODE_PULLNONE);
csi_gpio_pin_config_direction(pin, GPIO_DIRECTION_INPUT);
csi_gpio_pin_set_irq(pin, GPIO_IRQ_MODE_FALLING_EDGE, 1);
while (int_flag);
int_flag = 1;
csi_gpio_pin_uninitialize(pin);
printf("gpio falling_edge test passed!!!\n");
printf("test gpio successfully\n");
}
/*****************************************************************************
test_gpio: main function of the gpio test
INPUT: NULL
RETURN: NULL
*****************************************************************************/
int example_gpio(pin_name_e gpio_pin)
{
gpio_falling_edge_interrupt(gpio_pin);
return 0;
}
int main(void)
{
return example_gpio(EXAMPLE_GPIO_PIN);
}
|
7a7d19d2eb2b734c47ed58c32a25a0ad1d5d0b20
|
a20c54f73151ccdac7434fe3e1d251868f570d62
|
/Virtual_Machine/src/operator/i_sub.c
|
1a36d8300ba1ff51a242a4a279be95f01841dce5
|
[] |
no_license
|
Kinai42/Corewar
|
9f7a44d80ec9032caa4c67be5a0dd4b37fc88d7c
|
0a32c2a70da7ddd24ce24629775432efb47a47c7
|
refs/heads/master
| 2020-04-03T06:57:43.104025 | 2018-11-13T01:33:39 | 2018-11-13T01:33:39 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,282 |
c
|
i_sub.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* i_sub.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dbauduin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/21 16:20:47 by dbauduin #+# #+# */
/* Updated: 2018/11/13 02:04:04 by dbauduin ### ########.fr */
/* */
/* ************************************************************************** */
#include "vm.h"
/* ************************************************************************** */
/* ** Instructions: Same as add, but with the opcode est 0b101 (5 in decimal) */
/* ** and uses a substraction */
/* ************************************************************************** */
void i_sub(t_proc *processus, t_env *env)
{
t_var v;
int *tab;
int pc;
env->op = 5;
pc = set_pc(processus->pc + 1);
if ((tab = byte_analysis(&env->a[pc].hex)))
{
pc = set_pc(pc + 1);
if (!(is_reg_valid(v.p1 = (char)env->a[MODA(pc)].hex)))
return (return_error(processus, tab));
v.p4 = processus->reg[v.p1 - 1];
pc = set_pc(pc + 1);
if (!(is_reg_valid(v.p2 = (char)env->a[MODA(pc)].hex)))
return (return_error(processus, tab));
v.p5 = processus->reg[v.p2 - 1];
pc = set_pc(pc + 1);
if (!(is_reg_valid(v.p3 = (char)env->a[MODA(pc)].hex)))
return (return_error(processus, tab));
processus->reg[v.p3 - 1] = v.p4 - v.p5;
carry(processus, v.p4 - v.p5);
if (env->verbose >> 2 & 1)
ft_print(1, "P %d | sub r%d r%d r%d\n", processus->nbr, v.p1, v.p2, v.p3);
processus->pc = set_pc(pc + 1);
free(tab);
}
else
processus->pc = set_pc(processus->pc + 5);
}
|
901b2dbc12b5d8e15607c8aaf8b1368d883d3a46
|
3a56b1155d39c8e4dfaff52f0ec2e43b64304c28
|
/frames/00061.c
|
5e8af69b141f18d671be181ebbde2be1fd9e533b
|
[] |
no_license
|
RippedOrigami/GBA-Rick
|
6a610bde18e8dda978730b2d754565e9cdcbfe1d
|
0953de71ad0a392f5d3a0bcedc54d55e478925b7
|
refs/heads/master
| 2021-05-28T17:10:33.260039 | 2014-11-28T17:14:04 | 2014-11-28T17:14:04 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 6,281 |
c
|
00061.c
|
//{{BLOCK(_0061)
//======================================================================
//
// _0061, 40x40@8,
// + palette 256 entries, not compressed
// + 25 tiles lz77 compressed
// Total size: 512 + 1332 = 1844
//
// Time-stamp: 2014-11-28, 05:19:35
// Exported by Cearn's GBA Image Transmogrifier, v0.8.12
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
const unsigned int _0061Tiles[333] __attribute__((aligned(4))) __attribute__((visibility("hidden")))=
{
0x00064010,0x0A626200,0x526B620A,0x07A0A852,0x0A0F3062,0x62110700,0x6B6B040A,0x303E520A,
0x013E3C07,0x3C626262,0x103E6B6B,0x10624007,0x53773A07,0x00152641,0x773A1515,0x152B41A7,
0x3A080804,0x07008A77,0x3A002B2B,0x2B514B77,0x023C2B26,0x7F977778,0x07002B2B,0x20284459,
0x42C27D07,0x1B2B0F10,0x20212D20,0x6A521507,0x1B021B50,0x2B524082,0x6A070082,0x3C2B3F00,
0x306C5082,0x3C3A004F,0x505D822B,0x78041B50,0x6D8B2B2B,0x2B1B0700,0x07100840,0x152B1B50,
0x2700506D,0x26502727,0x00695082,0x27692127,0x5D1B3F52,0x6A781B00,0x323F260E,0x7850005D,
0x3F3F326A,0x50241B78,0x3F11006C,0x3207103F,0x153F0078,0x126C6C6A,0x82008B1C,0x7D7D4040,
0x00501C1B,0x5C826A4F,0xBA786A3F,0x8B8B6D00,0x3F3F5151,0x383E0152,0x38381E38,0x4A078038,
0x5F07901D,0x251F4063,0xC81E2750,0x07602E10,0x3B114040,0x80406363,0x26520810,0x3F3F3F26,
0x5F26013F,0x5C3F515C,0x080A005C,0x5C5C5C5A,0x5A180300,0x00364046,0x465C5C09,0x40363646,
0x460A005C,0x36515146,0x01108036,0x9C58106C,0x002B332B,0x5EA36C2B,0x33332B7B,0xA3843300,
0x3333C07C,0x5E640264,0x647F7CA3,0x009E0700,0x0DAF7CA3,0x9E2F0D0D,0x93AD9B01,0x0D413A3A,
0x49010700,0xA6A62979,0x0710A39E,0x33392900,0x212E693A,0x2E212021,0x21210700,0x007A7A28,
0x6F213A33,0x216F2821,0x07102640,0x2F692E21,0xA100693A,0x30276969,0x0030410D,0x30696958,
0x4DA6A64F,0x7C585800,0x29862939,0x5842024D,0x2E29394D,0x007D7D01,0x9226405C,0x6C5D502E,
0x3F3F7D00,0x272E2E2E,0x786C1427,0x506B013F,0x3A6A0700,0x6C6C3900,0x1B1B4D27,0x6C4F005C,
0x50275830,0x8800461B,0x5E9E5E4D,0x00417D50,0x9A4D4D8F,0x525C505E,0x0F111D4A,0x07D01E1E,
0x3E17401D,0x902F41F0,0x40011007,0x51515607,0x11516051,0x5107101A,0x26518E51,0x01302661,
0x2B2B2312,0x6B113396,0x63383800,0x2A2A2A63,0xBFBF1CBF,0x30AD015B,0x6252200F,0x01524163,
0x29A69307,0x27018673,0x29299300,0x59287329,0x0700801A,0x85427313,0x00739388,0x7A739329,
0x459373A0,0x71724900,0x8C49487A,0x45AF0045,0x939DA231,0x8800498C,0x9D8D35BC,0x00939373,
0x8643B281,0xB0AC7C73,0x49733400,0x80314D39,0x95B100AA,0x74954781,0xA9002003,0xA5B59191,
0x009F163D,0x57A90B0B,0xA9A93D0B,0x0BB48700,0x910BB455,0xBD8300A9,0x8306550B,0x3D013D43,
0x3D434343,0x06009191,0x02493D00,0x0273471A,0x347D0021,0xB39A71B3,0x6C005395,0x57577483,
0x00B8B1B2,0x4391A927,0x1F3D9F9F,0x0B0B6C00,0x3D4C7089,0x878408B8,0x12009891,0x00835EAB,
0x3DB70303,0x3D8F85B1,0x35B14C00,0x415EA8B0,0x01634163,0x6E6E6E0F,0x31115263,0x636E1E09,
0x1E072026,0x80070025,0x37511010,0x3E3E2552,0x783E003E,0x1D525F5C,0x5600613E,0x373F468F,
0x46636326,0x26AB1163,0x95022526,0x31628D03,0x07002663,0x1E26B713,0x10CF031E,0x03265211,
0x22620ABD,0x13154026,0x152262A7,0x00671140,0x22226211,0x22224040,0x22082202,0x008240AE,
0x22002207,0xA26A824E,0x0088889D,0x2C2C7688,0x9A8814A2,0x657E9A00,0x397A1465,0x4B580042,
0x6F14BE76,0x7C004239,0x7A447681,0x00303A2E,0xA09D5839,0x7D0D5092,0x30304F00,0x0D8B0930,
0xA48B003A,0x8BBA8B4F,0x3A000D15,0x8015823A,0x00B9653D,0x65BBB94C,0x43194343,0x3DB78000,
0x44446694,0x90900090,0x44BE8AC1,0xA301B890,0x8D84218A,0x6202A28D,0x275C7800,0x373F7D27,
0x3F3F0037,0x15153A8B,0x40282626,0x15BC0040,0xB1400600,0x05B30095,0x84841A0F,0x0F009A0C,
0x841A7C0F,0x436C8488,0x7D01006C,0x3346467D,0x2C4E1330,0x55034026,0x10193237,0x203B3BC1,
0x0740523B,0x5C7D6C3B,0x02515236,0x07408F35,0x0F105A7D,0x23374C37,0x0036366E,0x37911371,
0x25260037,0x3F37264A,0x25003636,0x1D3E3E1D,0x22171752,0x5F013B3B,0x110E173B,0x40184007,
0x17018B15,0x7826F504,0x4F821026,0x9749036D,0x01B6147A,0xA7A08D23,0xF0000085,0x05908201,
0x15823069,0x2EFF04AE,0x33153010,0x4B150605,0x5E409E48,0x59993F13,0x85850101,0xF028A03B,
0x0403B031,0x3B04152F,0x1090E110,0x200D4006,0x69222206,0x0730F978,0x03B031F0,0x0E01D101,
0x17213B75,0x543B220B,0x68010054,0x04300520,0xB031F0E0,0x753B0003,0x07245460,0x003800C1,
0x54242406,0x01000454,0x100520F0,0xC03FF006,0x00626501,
};
const unsigned short _0061Pal[256] __attribute__((aligned(4))) __attribute__((visibility("hidden")))=
{
0x0000,0x318B,0x4A72,0x0C84,0x6291,0x3E0F,0x1D28,0x5A71,
0x6294,0x4E0F,0x6AB4,0x14E7,0x35CD,0x5A94,0x5671,0x4230,
0x2D49,0x6694,0x4E50,0x4E74,0x41CD,0x5E94,0x10A6,0x5A92,
0x5692,0x1D07,0x4651,0x5251,0x5271,0x66D4,0x6AD4,0x2928,
0x0463,0x460F,0x6293,0x398B,0x5E92,0x62D4,0x5EB4,0x4A30,
0x41EE,0x5273,0x6AD6,0x62B5,0x1084,0x3149,0x4A0F,0x5A95,
0x4E31,0x31AD,0x5651,0x5EB5,0x39EF,0x254A,0x56B3,0x5AB3,
0x6AD5,0x4E52,0x5673,0x62B3,0x66B5,0x14C6,0x66D5,0x5A93,
0x5E93,0x5694,0x41EF,0x18E7,0x20E7,0x4A73,0x5293,0x4652,
0x3DCD,0x4E94,0x5ED4,0x39AD,0x10A5,0x4A31,0x5E72,0x5252,
0x4E30,0x5AB4,0x62B4,0x358B,0x6292,0x256B,0x6AF5,0x214A,
0x4610,0x316A,0x5292,0x66D6,0x5693,0x5230,0x4630,0x5EB3,
0x62B2,0x66F5,0x66B4,0x62D5,0x5E95,0x18C6,0x2108,0x6693,
0x6692,0x4A10,0x5A72,0x6AB5,0x4E51,0x5231,0x6AF4,0x45EF,
0x08A5,0x3E10,0x4E95,0x4E73,0x1908,0x66B3,0x294A,0x356A,
0x5672,0x5674,0x45EE,0x5ED6,0x4631,0x5272,0x2D6B,0x5AB5,
0x14A5,0x39CE,0x5A73,0x14E6,0x4A51,0x316B,0x4E53,0x1507,
0x4A52,0x10E6,0x35AC,0x5652,0x4E93,0x398C,0x56B4,0x4E72,
0x2107,0x10C6,0x49EF,0x5294,0x2128,0x35AD,0x5ED5,0x3DCE,
0x0CC5,0x2D4A,0x4210,0x296A,0x5AD5,0x3DAD,0x420F,0x10C5,
0x39AC,0x45F0,0x41CE,0x2D6A,0x5232,0x2109,0x5274,0x358C,
0x39EE,0x0CA5,0x0C83,0x2929,0x2D8C,0x4231,0x5E73,0x52B5,
0x296B,0x1D08,0x2129,0x3DEF,0x1D29,0x35AE,0x3D8C,0x10A4,
0x2949,0x14C5,0x4E10,0x18E6,0x35CE,0x1508,0x2508,0x6AF6,
0x5AD6,0x2D69,0x314A,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
};
//}}BLOCK(_0061)
|
0c704bd7ae2338e7516ca158907f2eb2b2486a67
|
dcf26a6bcf853a3f8f6f50f9379998ef4d8aad40
|
/drivers/liteos/tzdriver/src/tz_spi_notify.c
|
341c711c43dd84a4de2fd0d73e65d76a8a669331
|
[] |
no_license
|
small-seven/testmem
|
c5f3202dce1c369e9d84cdaaccc2008b827c16d8
|
2771460c617439bd1be562ffdc94543ea170a736
|
refs/heads/main
| 2023-03-12T22:16:28.824577 | 2021-03-03T04:24:59 | 2021-03-03T04:24:59 | 343,847,762 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 851 |
c
|
tz_spi_notify.c
|
#include "tz_spi_notify.h"
#include <securec.h>
#include "gp_ops.h"
#include "mailbox_mempool.h"
#include "smc.h"
#include "tc_client_driver.h"
#include "tc_client_sub_driver.h"
#include "tc_ns_client.h"
#include "tc_ns_log.h"
#include "teek_client_constants.h"
#define MAX_CALLBACK_COUNT 100
#define UUID_SIZE 16
#ifdef DEF_ENG
#endif
#ifdef CONFIG_TEE_SMP
#endif
#ifdef CONFIG_TEE_SMP
#endif
#define NOTIFY_DATA_ENTRY_COUNT \
#ifdef CONFIG_TEE_SMP
#endif
#ifdef CONFIG_TEE_SMP
#endif
#ifdef CONFIG_TEE_SMP
#endif
#ifdef CONFIG_TEE_SMP
#else
#endif
#ifdef CONFIG_TEE_SMP
#define N_WORK 8
#undef N_WORK
#else
#endif
#ifdef DEF_ENG
#define PARAM1 1
#define DUMP_UUID_INDEX0 0
#define DUMP_UUID_INDEX1 1
#define DUMP_UUID_INDEX2 2
#define DUMP_UUID_INDEX3 3
#endif
#ifdef CONFIG_TEE_SMP
#endif
#ifdef CONFIG_TEE_SMP
#endif
#ifdef CONFIG_TEE_SMP
#endif
|
af8296fe2a10c417f4f76f289d28e6d03b2c5269
|
5888753984aacbc60d9512c73590387ef4b17022
|
/vesper_test/vsp_test_cmcp_connection.c
|
4516c7ec042f8879ca793a0c0ee772bf31291cc2
|
[
"BSD-3-Clause"
] |
permissive
|
ClundXIII/vesper-libs
|
d58f04b5e19d846899a810b2f0024662694b0d19
|
597e395973c93c72da4d291a36b980b76fd6ef8c
|
refs/heads/master
| 2021-01-20T15:49:54.028301 | 2015-06-17T13:13:42 | 2015-06-17T13:13:42 | 20,058,871 | 0 | 0 | null | 2014-05-23T09:15:33 | 2014-05-22T11:40:02 |
C++
|
UTF-8
|
C
| false | false | 3,747 |
c
|
vsp_test_cmcp_connection.c
|
/**
* \file
* \authors Max Mertens
*
* Copyright (c) 2014, Max Mertens. All rights reserved.
* This file is licensed under the "BSD 3-Clause License".
* Full license text is under the file "LICENSE" provided with this code.
*/
#include "minunit.h"
#include "vsp_test.h"
#include <vesper_cmcp/vsp_cmcp_client.h>
#include <vesper_cmcp/vsp_cmcp_server.h>
#include <vesper_util/vsp_error.h>
#include <stddef.h>
#include <stdio.h>
/** Global CMCP server object. */
vsp_cmcp_server *global_cmcp_server;
/** Global CMCP client object. */
vsp_cmcp_client *global_cmcp_client;
/** Create global global_cmcp_server and global_cmcp_client objects. */
void vsp_test_cmcp_connection_setup(void);
/** Free global global_cmcp_server and global_cmcp_client objects. */
void vsp_test_cmcp_connection_teardown(void);
/** Test vsp_cmcp_server_create() and vsp_cmcp_server_free(). */
MU_TEST(vsp_test_cmcp_server_allocation);
/** Test vsp_cmcp_client_create() and vsp_cmcp_client_free(). */
MU_TEST(vsp_test_cmcp_client_allocation);
/** Test connection between vsp_cmcp_server and vsp_cmcp_client. */
MU_TEST(vsp_test_cmcp_connection_test);
void vsp_test_cmcp_connection_setup(void)
{
global_cmcp_server = vsp_cmcp_server_create();
global_cmcp_client = vsp_cmcp_client_create();
}
void vsp_test_cmcp_connection_teardown(void)
{
vsp_cmcp_client_free(global_cmcp_client);
vsp_cmcp_server_free(global_cmcp_server);
}
MU_TEST(vsp_test_cmcp_server_allocation)
{
vsp_cmcp_server *local_global_cmcp_server;
int ret;
/* allocation */
local_global_cmcp_server = vsp_cmcp_server_create();
mu_assert(local_global_cmcp_server != NULL, vsp_error_str(vsp_error_num()));
/* deallocation */
ret = vsp_cmcp_server_free(local_global_cmcp_server);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
}
MU_TEST(vsp_test_cmcp_client_allocation)
{
vsp_cmcp_client *local_global_cmcp_client;
int ret;
/* allocation */
local_global_cmcp_client = vsp_cmcp_client_create();
mu_assert(local_global_cmcp_client != NULL, vsp_error_str(vsp_error_num()));
/* deallocation */
ret = vsp_cmcp_client_free(local_global_cmcp_client);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
}
MU_TEST(vsp_test_cmcp_connection_test)
{
int ret;
/* bind */
ret = vsp_cmcp_server_bind(global_cmcp_server, SERVER_PUBLISH_ADDRESS,
SERVER_SUBSCRIBE_ADDRESS);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
/* connect */
ret = vsp_cmcp_client_connect(global_cmcp_client, SERVER_SUBSCRIBE_ADDRESS,
SERVER_PUBLISH_ADDRESS);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
/* start server */
ret = vsp_cmcp_server_start(global_cmcp_server);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
/* start client */
ret = vsp_cmcp_client_start(global_cmcp_client);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
/* stop client */
ret = vsp_cmcp_client_stop(global_cmcp_client);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
/* stop server */
ret = vsp_cmcp_server_stop(global_cmcp_server);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
/* disconnect */
ret = vsp_cmcp_client_disconnect(global_cmcp_client);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
/* unbind */
ret = vsp_cmcp_server_unbind(global_cmcp_server);
mu_assert(ret == 0, vsp_error_str(vsp_error_num()));
}
MU_TEST_SUITE(vsp_test_cmcp_connection)
{
MU_RUN_TEST(vsp_test_cmcp_server_allocation);
MU_RUN_TEST(vsp_test_cmcp_client_allocation);
MU_SUITE_CONFIGURE(&vsp_test_cmcp_connection_setup,
&vsp_test_cmcp_connection_teardown);
MU_RUN_TEST(vsp_test_cmcp_connection_test);
}
|
6cb2957948143cef8e1806cdd67091d937732c05
|
f60a08bc6f092af6a1ac7972bb382c8a6be4fdf6
|
/working_draft/libft/ft_strdup.c
|
d36bf3ed5b5562e12c9e470ef5dc0535a7b753d0
|
[] |
no_license
|
ukelly-s/Filler
|
1339c2f98ec355883df91c79b196fe6d40d52bcc
|
ae03fe7c4a3f2ba515fb648050f420b9292e9789
|
refs/heads/main
| 2022-12-20T14:26:19.615347 | 2020-10-04T08:14:05 | 2020-10-04T08:14:05 | 300,364,884 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 245 |
c
|
ft_strdup.c
|
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *src;
char *src1;
src = (char*)malloc(sizeof(char) * (ft_strlen(s1) + 1));
src1 = 0;
if (src)
{
src1 = src;
while (*s1)
*src++ = *s1++;
*src = '\0';
}
return (src1);
}
|
68b093358400b6c82ae74ebe81b98e189f166bb3
|
3b55a30c48c1d52416400e2a3f66af2fe97c6096
|
/src/commands.c
|
aff95a247a366b6f96017dff0b3ee803557deb79
|
[] |
no_license
|
BaptisteVeyssiere/n4s
|
ba0d3bd5ab7bd028aa127db29e53e41877922971
|
e20a218b105857fdf156e77b3beefdc55f8ba8a8
|
refs/heads/master
| 2020-06-12T01:20:20.340087 | 2019-06-27T19:16:09 | 2019-06-27T19:16:09 | 194,148,979 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,294 |
c
|
commands.c
|
/*
** commands.c for n4s in /home/scutar_n/rendu/CPE/CPE_2015_n4s/src
**
** Made by nathan scutari
** Login <[email protected]>
**
** Started on Sun May 29 16:39:50 2016 nathan scutari
** Last update Sun May 29 16:43:42 2016 nathan scutari
*/
#include <stdlib.h>
#include <unistd.h>
#include "ns.h"
int stop_sim(void)
{
char buff[501];
int ret;
if (write(1, "stop_simulation\n", 17) < 1 ||
(ret = read(0, buff, 500)) < 1)
return (1);
buff[ret] = 0;
if (buff[3] != 'O' || buff[4] != 'K')
return (1);
return (0);
}
int send_command(char *command, double value, t_info_lidar *lid)
{
char buff[501];
char *c_value;
int ret;
if (write(1, command, my_strlen(command)) < 1 ||
(c_value = double_to_char(value)) == NULL ||
write(1, c_value, my_strlen(c_value)) < 1 ||
write(1, "\n", 1) < 1 ||
(ret = read(0, buff, 500)) < 1)
return (1);
buff[ret] = 0;
free(c_value);
if (buff[6] != 'C')
if (verif_command_one(lid, buff) == -1)
return (1);
return (0);
}
int init_simulation(t_info_lidar *lid)
{
char buff[501];
int ret;
if (write(1, "start_simulation\n", 17) < 1 ||
(ret = read(0, buff, 500)) < 1)
return (1);
buff[ret] = 0;
if (verif_command_one(lid, buff))
return (1);
return (0);
}
|
9b3d8e8c07baab329772d47645ff4c090c3aa76f
|
d49716f205fe6db66a279de2215ceab7ec48b675
|
/2/2.c
|
0f57358d767901fecd26717940bd1c55f3a44967
|
[] |
no_license
|
Mikasa75/debug
|
be6143764de68d148c892d27ddbd771b86c47958
|
ac11c14a397bd43b4b796be8fdebd4c8956acd16
|
refs/heads/master
| 2022-11-06T08:37:06.419198 | 2020-07-01T15:22:52 | 2020-07-01T15:22:52 | 274,399,808 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 937 |
c
|
2.c
|
#include <stdio.h>
#include <string.h>
int main()
{
int matrix_a[10][10], matrix_b[10][10];
int m, n;
scanf("%d %d", &m, &n);
int i, j;
for (i=0; i<m; i++) {
for (j=0; j<n; j++) {
scanf("%d", &matrix_a[i][j]);
}
}
for (i=0;i<n;i++) {
for (j=0;j<m;j++) {
scanf("%d", &matrix_b[i][j]);
}
}
int matrix_c[m][m];
memset(matrix_c, 0, sizeof(int)*m*m);
int c;
for (i=0; i<m; i++) {
for(j=0; j<m; j++) {
for(c=0; c<n; c++) {
matrix_c[i][j] += matrix_a[i][c] * matrix_b[c][j];
}
}
}
for(i=0; i<m; i++) {
for(j=0; j<m; j++) {
if(j != m-1) {
printf("%d ", matrix_c[i][j]);
} else {
printf("%d\n", matrix_c[i][j]);
}
}
}
return 0;
}
|
35f53f49fac9ea7eeda12125e1d7528722bbde62
|
6ca994c7adfbe08c6d2c636d4eb599a8692fc087
|
/App/music_fire.h
|
c957b1a8ad6ded18ced730055d496cc8c3668028
|
[] |
no_license
|
Mrbuchixiangcai/GP-A012_NewPCB
|
a68ddef37c39dc0b33a2330474af44ed72a82a22
|
06a2e765894611167c2ed453da0a8b4dfa5f7c7c
|
refs/heads/master
| 2020-03-27T20:13:31.256524 | 2018-10-25T09:34:11 | 2018-10-25T09:34:11 | 147,049,949 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 164 |
h
|
music_fire.h
|
#ifndef __MUSIC_FIRE_H__
#define __MUSIC_FIRE_H__
#include "app_main.h"
extern void s_Music_Fire_Mode(void);
extern void Music_Fire_Mode(void);
#endif
|
6073d5b7b093bc822b54e42272b41cd1e114e2da
|
8441009050e1283c9a2c057292c95789c7fded2d
|
/code/comparisons/else_if_vs_switch.c
|
c337c5de3488dd43163beab59bb151f6e9935434
|
[] |
no_license
|
zhaol/ee160
|
6e3dabd198b5af7691dc40a49830b30518a1da45
|
50dc6cdddddf9af9c38d8f3967435dd934ae147b
|
refs/heads/gh-pages
| 2021-01-19T23:57:38.916183 | 2017-04-30T08:43:06 | 2017-04-30T08:43:06 | 12,017,010 | 0 | 2 | null | 2015-11-05T15:45:31 | 2013-08-10T06:55:13 |
HTML
|
UTF-8
|
C
| false | false | 1,116 |
c
|
else_if_vs_switch.c
|
/* File: else_if_vs_switch.c
// By: The Awesome Students of EE160
// Date: Today :)
*/
#include <stdio.h>
// This program compares using else if with switch
int main () {
int number = 201;
// else if can match ranges
if ((0 <= number) && (number < 100)) {
printf("The number is between 0 and 100, including 0\n");
} else if ((100 <= number) && (number < 200)) {
printf("The number is between 100 and 200, including 100\n");
} else if ((200 <= number) && (number < 300)) {
printf("The number is between 200 and 300, including 200\n");
} else {
printf("The number is not (0 - 100), (100 - 200), or (200 - 300)\n");
printf("The number is also not 0, 100, or 200\n");
}
// switch can only test for equality
switch (number) {
case 0:
printf("The number is 0\n");
break;
case 100:
printf("The number is 100\n");
break;
case 200:
printf("The number is 200\n");
break;
default:
printf("The number is not 0, 100, or 200\n");
}
return 0;
}
|
b473fe3214a3d6291e3f68fb276f52c2abf3d4b9
|
ee0ac64d8a496fd99ebbf2df4686eec46d8f4b84
|
/student-distrib/drivers/graphic_terminal.c
|
7b0fd640541e5697bc188e7c3d0731b609310c41
|
[] |
no_license
|
devmanaktala10/XanOS
|
b42f541b39ec4a5c49cbff0af5f08c47c43d57a3
|
af3a18bad91a693ccf328770980c0ecd330c670f
|
refs/heads/main
| 2023-06-24T12:00:24.146721 | 2021-07-17T21:40:18 | 2021-07-17T21:40:18 | 386,815,225 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 19,011 |
c
|
graphic_terminal.c
|
#include "graphic_terminal.h"
static const uint32_t vidloc = 0xFC000000;
/* terminal_open
* DESCRIPTION: initializes the current terminal and sets the
* cursor via calling helper reset term function
* INPUTS: None
* OUTPUTS: None
* RETURN VALUE: 0 for success
* SIDE EFFECTS: clears the screen and the terminal
*/
int32_t graphic_terminal_open() {
int x;
for(x = 0; x < NUM_GRAPH_TERMINALS; x++){
gterminals[x].screen_x = 0;
gterminals[x].screen_y = 0;
gterminals[x].read_mode = 0;
gterminals[x].buffer_counter = 0;
gterminals[x].executed = 0;
gterminals[x].disabled = 0;
gterminals[x].background = COLOR_EXPAND_WHITE;
gterminals[x].text = COLOR_EXPAND_BLACK;
gterminals[x].r1_mode = 0;
memset(gterminals[x].read, 0x00, 128);
memset((void *)(vidloc + TERMINAL_0_START_OFFSET + x * TERMINAL_SIZE), 0x00, 32*1024);
}
terminal_bitmap = 0;
curterm = 0;
return 0;
}
void write_char_graphic_helper(char input){
unsigned long flags;
cli_and_save(flags);
if(curterm == -1) return;
if(keyint){
if(gterminals[curterm].disabled != 1){
write_char_graphic(input, curterm);
}
}
else{
if(curterm == process_term){
write_char_graphic(input, curterm);
}
else{
write_char_graphic(input, process_term);
}
}
restore_flags(flags);
}
/* write_char_current
* DESCRIPTION: Write a character onto the screen. Adjust the buffer values accordingly,
* set the cursor and handle scrolling and backspaces.
* INPUTS: char input - char to display
* OUTPUTS: None
* RETURN VALUE: None
* SIDE EFFECTS: the character gets printed
*/
void write_char_graphic(char input, int terminal){
/* if a newline character came in */
if(input == NEWLINE){
/* if we are currently reading, then stop the read mode and put a \n in the buffer */
if(gterminals[terminal].read_mode == 1 && terminal == curterm){
gterminals[terminal].read_mode = 0;
gterminals[terminal].read[gterminals[terminal].buffer_counter++] = '\n';
}
/* go to next line, reset the x position, increase the y position */
gterminals[terminal].screen_x = 0;
gterminals[terminal].screen_y++;
/* if the screen_y position goes out of the screen, we need to scroll */
if(gterminals[terminal].screen_y >= NUM_ROWS){
/* scroll the screen */
scroll_up_graphic(terminal);
}
}
/* if a backspace character came in */
else if(input == BACKSPACE){
/* if we are currently reading */
if(gterminals[terminal].read_mode == 1 && terminal == curterm){
/* if the read buffer is already empty do nothing */
if(gterminals[terminal].r1_mode){
gterminals[terminal].read_mode = 0;
gterminals[terminal].read[gterminals[terminal].buffer_counter++] = (char)1;
}
else if(gterminals[terminal].buffer_counter == 0){
gterminals[terminal].buffer_counter = 0;
return;
}
/* else remove the current head from the read buffer */
else
gterminals[terminal].read[--(gterminals[terminal].buffer_counter)] = '\0';
}
/* make the x position go back */
gterminals[terminal].screen_x--;
/* if the x goes beyond the screen and we are not in the left corner */
if(gterminals[terminal].screen_x < 0 && gterminals[terminal].screen_y > 0){
/* move up */
gterminals[terminal].screen_y--;
/* go the most right you can and then move backwards till you get a character */
gterminals[terminal].screen_x = NUM_COLS - 1;
/* make the current last character NULL */
uint32_t start = TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE + (gterminals[terminal].screen_y * NUM_COLS * 16 + gterminals[terminal].screen_x);
blt_operation_mmio(0, 0, 0, 15, 80, 1, start, FONTDATAFBA, 0, 0, BLT_DST_ROP, 0, 0);
// char * start = (char *)(0xFC000000 + TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE + (gterminals[terminal].screen_y * NUM_COLS * 16 + gterminals[terminal].screen_x));
// char * buffer = (char *)font_data[0];
// int x;
// for(x = 0; x < 16; x++){
// *(start + x*80) = buffer[x];
// }
/* clear the buffer character */
while( 0 == is_null_graphic(gterminals[terminal].screen_x - 1, gterminals[terminal].screen_y, terminal)) { // *(uint8_t *)(video_mem + ((NUM_COLS * current->screen_y + (current->screen_x - 1)) << 1)) == '\0'){
gterminals[terminal].screen_x--;
/* if there is nothing on the line, then stay at the left of that line */
if(gterminals[terminal].screen_x <= 0){
gterminals[terminal].screen_x = 0;
break;
}
}
}
/* if in the top left, just stay there */
else if(gterminals[terminal].screen_x < 0){
gterminals[terminal].screen_x = 0;
}
/* otherwise, remove a character from the buffer and write null on the screen */
else{
uint32_t start = TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE + (gterminals[terminal].screen_y * NUM_COLS * 16 + gterminals[terminal].screen_x);
blt_operation_mmio(0, 0, 0, 15, 80, 1, start, FONTDATAFBA, 0, 0, BLT_DST_ROP, 0, 0);
// char * start = (char *)(0xFC000000 + TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE + (gterminals[terminal].screen_y * NUM_COLS * 16 + gterminals[terminal].screen_x));
// char * buffer = (char *)font_data[0];
// int x;
// for(x = 0; x < 16; x++){
// *(start + x*80) = buffer[x];
// }
}
}
/* for any other character */
else{
/* if we are reading */
if(gterminals[terminal].read_mode == 1 && terminal == curterm){
/* if we still have room to read, put character in the read buffer */
if(gterminals[terminal].r1_mode == 1){
gterminals[terminal].read_mode = 0;
gterminals[terminal].read[gterminals[terminal].buffer_counter++] = input;
}
else if(gterminals[terminal].buffer_counter < MAX_READ - 1){
gterminals[terminal].read[gterminals[terminal].buffer_counter++] = input;
}
}
/* put the character on the screen and the buffer */
uint8_t index = (uint8_t) input;
uint32_t start = TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE + (gterminals[terminal].screen_y * NUM_COLS * 16 + gterminals[terminal].screen_x);
blt_operation_mmio(0, 0, 0, 15, 80, 1, start, FONTDATAFBA + index * 16, 0, 0, BLT_DST_ROP, 0, 0);
// char * start = (char *)(0xFC000000 + TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE + (gterminals[terminal].screen_y * NUM_COLS * 16 + gterminals[terminal].screen_x));
// char * buffer = (char *)font_data[index];
// int x;
// for(x = 0; x < 16; x++){
// *(start + x*80) = buffer[x];
// }
gterminals[terminal].screen_x++;
/* if we have gone beyond the screen, move down*/
if(gterminals[terminal].screen_x >= NUM_COLS){
/* reset x to left */
gterminals[terminal].screen_x = 0;
gterminals[terminal].screen_y++;
/* if moving down causes you to go out, then scroll */
if(gterminals[terminal].screen_y >= NUM_ROWS){
/* increment the scroll counter */
scroll_up_graphic(terminal);
}
}
}
}
int is_null_graphic(int x, int y, int terminal){
int i;
char * start = (char *)(vidloc + TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE + (y * NUM_COLS * 16 + x));
for(i = 0; i < 16; i++){
if(*(start + i*80) != 0x00) return -1;
}
return 0;
}
void scroll_up_graphic(int terminal){
uint32_t start = TERMINAL_0_START_OFFSET + terminal * TERMINAL_SIZE;
blt_operation_mmio(0, 0, 80 - 1, 24*16 - 1, 80, 80, start, start + 80*16, 0, 0, BLT_DST_ROP, 0, 0);
blt_operation_mmio(0, 0, 80 - 1, 16 - 1, 80, 80, start + 80*16*24, 0, 0, 0, 0, 0, 0);
gterminals[terminal].screen_y = NUM_ROWS - 1;
gterminals[terminal].screen_x = 0;
}
/* read_buffer
* DESCRIPTION: read the input values from the terminal till a newline. Max size of read is 128.
* INPUTS: void * buffer - buffer to write to
* int32_t nbytes - number of bytes to read
* OUTPUTS: None
* RETURN VALUE: None
* SIDE EFFECTS: The cursor gets set at the current x,y values
*/
int32_t read_graphic_terminal(void * buffer, int32_t nbytes){
/* check for NULL buffer */
if(buffer == NULL){
return 0;
}
/* make read mode 1 */
gterminals[process_term].read_mode = 1;
/* write char will set this to zero when new line entered */
while(gterminals[process_term].read_mode == 1);
if(gterminals[process_term].r1_mode){
*((uint8_t *)(buffer)) = (uint8_t)gterminals[process_term].read[0];
gterminals[process_term].buffer_counter = 0;
gterminals[process_term].read[0] = '\0';
return 1;
}
/* if len of buffer is less than how much has been read, then read till len of buffer */
int limit = 0;
if(nbytes > gterminals[process_term].buffer_counter)
limit = gterminals[process_term].buffer_counter;
else
limit = nbytes;
/* put read buffer into input buffer */
int i = 0;
for(i = 0; i < limit; i++){
*((uint8_t *)(buffer + i)) = (uint8_t)gterminals[process_term].read[i];
}
/* the last character should always be new line */
*((uint8_t *)(buffer + limit - 1)) = (uint8_t)('\n');
uint32_t main_arg_counter = set_args_graphic(buffer, limit);
/* reset the read buffer */
for(i = 0; i < gterminals[process_term].buffer_counter; i++){
gterminals[process_term].read[i] = '\0';
}
/* reset current */
gterminals[process_term].buffer_counter = 0;
return main_arg_counter;
}
uint32_t set_args_graphic(uint8_t* buf, int32_t length) {
if (length <= 0) {
return 0;
}
g_args[0] = '\0';
char main_arg[MAX_FILENAME_LENGTH];
uint32_t main_arg_counter = 0;
unsigned i = 0;
while (buf[i] == ' ') {
i++;
}
while (i < length - 1 && buf[i] != ' ') {
main_arg[main_arg_counter++] = buf[i];
i++;
}
main_arg[main_arg_counter] = '\n';
g_arg_counter = 0;
i++;
while (i < length - 1) {
g_args[g_arg_counter++] = buf[i++];
}
g_args[g_arg_counter] = '\0';
memcpy(buf, main_arg, main_arg_counter + 1);
buf[main_arg_counter + 1] = '\0';
return main_arg_counter + 1;
}
/* write_terminal
* DESCRIPTION: write the input buffer onto the screen
* INPUTS: void * buffer - buffer to write
* int32_t nbytes - number of bytes to write
* OUTPUTS: None
* RETURN VALUE: None
* SIDE EFFECTS: writes the buffer to the terminal
*/
int32_t write_graphic_terminal(const void * buf, int32_t nbytes){
/* check for NULL buffer */
if(buf == NULL){
return 0;
}
int i;
/* write the buffer character by character */
for(i = 0; i < nbytes; i++){
char c = *((char *)(buf) + i);
write_char_graphic_helper(c);
}
return nbytes;
}
void redraw_screen_graphic(){
int i;
for(i = 0; i < NUM_GRAPH_TERMINALS; i++){
if(gterminals[i].executed == 0) continue;
uint32_t start = TERMINAL_0_START_OFFSET + i*TERMINAL_SIZE;
blt_operation_mmio(0xFFFFFFFF, 0xFEFEFEFE, 80*8 - 1, 25*16 - 1, 1280, 80*4, 1024*1280+(80*8*(i%2) + 20) + (i/2)*(25*16+25)*(1280), start, 0, BLT_COLOR_EXPANSION | 0x01, BLT_DST_ROP, 0, 0);
}
}
int32_t graphic_printf(int8_t * format, ...){
/* Pointer to the format string */
int8_t* buf = format;
/* Stack pointer for the other parameters */
int32_t* esp = (void *)&format;
esp++;
while (*buf != '\0') {
switch (*buf) {
case '%':
{
int32_t alternate = 0;
buf++;
format_char_switch:
/* Conversion specifiers */
switch (*buf) {
/* Print a literal '%' character */
case '%':
write_char_graphic_helper('%');
break;
/* Use alternate formatting */
case '#':
alternate = 1;
buf++;
/* Yes, I know gotos are bad. This is the
* most elegant and general way to do this,
* IMHO. */
goto format_char_switch;
/* Print a number in hexadecimal form */
case 'x':
{
int8_t conv_buf[64];
if (alternate == 0) {
itoa(*((uint32_t *)esp), conv_buf, 16);
write_graphic_terminal(conv_buf, strlen(conv_buf));
} else {
int32_t starting_index;
int32_t i;
itoa(*((uint32_t *)esp), &conv_buf[8], 16);
i = starting_index = strlen(&conv_buf[8]);
while(i < 8) {
conv_buf[i] = '0';
i++;
}
write_graphic_terminal(&conv_buf[starting_index], strlen(&conv_buf[starting_index]));
}
esp++;
}
break;
/* Print a number in unsigned int form */
case 'u':
{
int8_t conv_buf[36];
itoa(*((uint32_t *)esp), conv_buf, 10);
write_graphic_terminal(conv_buf, strlen(conv_buf));
esp++;
}
break;
/* Print a number in signed int form */
case 'd':
{
int8_t conv_buf[36];
int32_t value = *((int32_t *)esp);
if(value < 0) {
conv_buf[0] = '-';
itoa(-value, &conv_buf[1], 10);
} else {
itoa(value, conv_buf, 10);
}
write_graphic_terminal(conv_buf, strlen(conv_buf));
esp++;
}
break;
/* Print a single character */
case 'c':
write_char_graphic_helper((uint8_t) *((int32_t *)esp));
esp++;
break;
/* Print a NULL-terminated string */
case 's':
write_graphic_terminal(*((int8_t **)esp), strlen(*((int8_t **)esp)));
esp++;
break;
default:
break;
}
}
break;
default:
write_char_graphic_helper(*buf);
break;
}
buf++;
}
return (buf - format);
}
void reset_graphic_term(int term){
uint32_t start = TERMINAL_0_START_OFFSET + term * TERMINAL_SIZE;
blt_operation_mmio(0, 0, 80 - 1, 25*16 - 1, 80, 80, start, 0, 0, 0, 0, 0, 0);
memset(gterminals[term].read, 0, 128);
gterminals[term].screen_x = 0;
gterminals[term].screen_y = 0;
}
int switch_graphic_terminal(int newterm) {
unsigned long flags;
cli_and_save(flags);
if (curterm == newterm) {
restore_flags(flags);
return 0;
}
bring_front(&(gui_root.children), &(gui_root.children_tail), newterm);
if(gterminals[newterm].executed == 0){
prevterm = curterm;
curterm = newterm;
restore_flags(flags);
return 1;
}
curterm = newterm;
restore_flags(flags);
return 0;
}
void render_graphic_terminal(void * element){
gui_element_t * t = (gui_element_t *) element;
int i = t->id - 1;
graphic_terminal_t terminal = gterminals[i];
if(terminal.executed == 0) return;
int x = t->x;
int y = t->y;
uint32_t start = TERMINAL_0_START_OFFSET + i*TERMINAL_SIZE;
blt_operation_mmio(0, 0, BAR_WIDTH - 1, BAR_HEIGHT - 1, SCREEN_WIDTH, BAR_WIDTH, DRAWINGBOARDFBA + x + SCREEN_WIDTH*y, BARFBA, 0, 0, BLT_DST_ROP, 0, 0);
blt_operation_mmio(gterminals[i].background, gterminals[i].text, TERMINAL_WIDTH - 1, TERMINAL_HEIGHT - BAR_HEIGHT - 1, SCREEN_WIDTH, TERMINAL_WIDTH, DRAWINGBOARDFBA + x + (y+BAR_HEIGHT)*SCREEN_WIDTH, start, 0, BLT_COLOR_EXPANSION, BLT_DST_ROP, 0, 0);
}
void set_graphic_terminal_title(int term, char * title){
char * start = (char *)(0xFC000000 + TERMINAL_0_START_OFFSET + term * TERMINAL_SIZE + GRAPHICAL_TERMINAL_TITLE_OFFSET);
int i;
for(i = 0; i < 48; i++){
uint8_t index = (uint8_t) (title[i]);
char * buffer = (char *)font_data[index];
int x;
for(x = 0; x < 16; x++){
*(start + x*48) = buffer[x];
}
start++;
}
}
void set_terminal_bitmap(uint32_t index, int val){
if(val == 1)
terminal_bitmap |= (0x01 << index);
else
terminal_bitmap &= (~(0x01 << index));
}
int get_terminal_bitmap(uint32_t index){
if(terminal_bitmap & (0x01 << index)) return 1;
else return 0;
}
int find_free_terminal(){
uint32_t i = 0;
unsigned long flags;
cli_and_save(flags);
for(i = 0; i < 10; i++){
if(get_terminal_bitmap(i) == 0){
set_terminal_bitmap(i, 1);
restore_flags(flags);
return i;
}
}
return -1;
restore_flags(flags);
}
void free_terminal (uint32_t index){
unsigned long flags;
cli_and_save(flags);
set_terminal_bitmap(index, 0);
restore_flags(flags);
}
|
066ec616e584510c7932e5b950a92130ac51e1e6
|
05463ff11db771d1f4e6c554b62ab2eb590438f2
|
/SOFT/STEND/kontr/uart1.c
|
2994f3ce09c00552ee43227aabda633ebccd60f1
|
[] |
no_license
|
pal73/FAT93
|
a448cad5a18836ff341096576255777f018b51c2
|
de7fd381a98f2b9fe08fa2572af02d669c821ea0
|
refs/heads/master
| 2020-08-03T17:47:05.988301 | 2020-01-21T18:52:38 | 2020-01-21T18:52:38 | 211,832,699 | 0 | 0 | null | null | null | null |
WINDOWS-1251
|
C
| false | false | 18,402 |
c
|
uart1.c
|
#include "stm8s.h"
#include "main.h"
#include "uart1.h"
#include <string.h>
#include <stdlib.h>
#include "modem.h"
#include <stdio.h>
#include "lowlev.h"
#include "ds18b20.h"
#include "next_version.h"
//-----------------------------------------------
@near char rxBuffer1[RX_BUFFER_1_SIZE]; //Приемный буфер UART1
@near char txBuffer1[TX_BUFFER_1_SIZE]; //Передающий буфер UART1
@near short rx_wr_index1; //Указатель на следующий принимаемый байт
@near short tx_wr_index1; //Указатель на следующую ячейку передающего ФИФО
@near short tx_rd_index1; //Указатель на следующий отправляемый из ФИФО байт
@near short tx_counter1; //Счетчик заполненности передающего ФИФО
@near char uart1_an_buffer[350]; //Буфер для анализа принятых по UART1 строк
@near char bRXIN1; //Индикатор принятой строки в uart1_an_buffer
@near char incommingNumber[10]; //Буфер для хранения номера отправителя пришедшей смс
@near char incommingNumberToMain[10]; //Буфер для хранения номера просящегося в главные
@near char incommingNumberUSSDRequ[10]; //Буфер для хранения номера приславшео USSD запрос
bool isFromMainNumberMess; //флаг, пришедшее смс от мастерского телефона
bool isFromAutorizedNumberMess; //флаг, пришедшее смс от одного из прописанных немастерских телефонов
bool isFromNotAutorizedNumberMess; //флаг, пришедшее смс от неавторизованного телефона
bool bOK; //Модем ответил "OK"
bool bERROR; //Модем ответил "ERROR"
bool bINITIALIZED; //Модем инициализирован
char ussdRequ; //Был USSD запрос
char bCBC; //модем ответил CBC
bool bBUY_SMS; //Прощальное SMS ушло
@near char cbcRequ; //Был запрос состояния аккумулятора
@near char* number_temp;
@near short cell;
//-----------------------------------------------
//Отладка
@near char uart1_plazma;
@near char modem_plazma;
@near char modem_plazma1;
//char *ptr1;
//char *ptr2;
//char *digi;
//-----------------------------------------------
void uart1_init (void)
{
GPIOA->DDR&=~(1<<4);
GPIOA->CR1|=(1<<4);
GPIOA->CR2&=~(1<<4);
GPIOA->DDR|=(1<<5);
GPIOA->CR1|=(1<<5);
GPIOA->CR2|=(1<<5);
UART1->CR1&=~UART1_CR1_M;
//UART1->CR2|= 0x0c;
UART1->CR3|= (0<<4) & UART1_CR3_STOP;
UART1->BRR2= 0x02;//0x03;
UART1->BRR1= 0x41;//0x68;
UART1->CR2|= UART3_CR2_TEN | UART1_CR2_REN | UART1_CR2_RIEN /*| UART1_CR2_TIEN*/;
}
//***********************************************
@far @interrupt void UART1RxInterrupt (void)
{
char rx_status1=UART1->SR;
char rx_data1=UART1->DR;
if (rx_status1 & (UART1_SR_RXNE))
{
if(rx_data1=='\r')
{
memset(uart1_an_buffer,'\0',200);
memcpy(uart1_an_buffer,rxBuffer1,rx_wr_index1);
bRXIN1=1;
rx_wr_index1=0;
}
else if(rx_data1=='>')
{
bOK=1;
rx_wr_index1=0;
}
else if(rx_data1!='\n')
{
rxBuffer1[rx_wr_index1++]=rx_data1;
if(rx_wr_index1>=RX_BUFFER_1_SIZE)
{
rx_wr_index1=0;
}
}
if(rx_wr_index1>=1)
{
cntAirSensorLineErrorLo=0;
}
/* cntAirSensorLineErrorHi=0;
if(airSensorErrorStat==taesLHI)airSensorErrorStat=taesNORM;
if(airSensorErrorStat==taesLLO)airSensorErrorStat=taesNORM;*/
}
}
//***********************************************
@far @interrupt void UART1TxInterrupt (void)
{
if (tx_counter1)
{
--tx_counter1;
UART1->DR=txBuffer1[tx_rd_index1];
if (++tx_rd_index1 == TX_BUFFER_1_SIZE) tx_rd_index1=0;
}
else
{
//bOUT_FREE=1;
UART1->CR2&= ~UART1_CR2_TIEN;
}
}
//-----------------------------------------------
void putchar1(char c)
{
while (tx_counter1 == TX_BUFFER_1_SIZE);
disableInterrupts();
if (tx_counter1 || ((UART1->SR & UART1_SR_TXE)==0))
{
txBuffer1[tx_wr_index1]=c;
if (++tx_wr_index1 == TX_BUFFER_1_SIZE) tx_wr_index1=0;
++tx_counter1;
}
else UART1->DR=c;
enableInterrupts();
UART1->CR2|= UART1_CR2_TIEN;
}
//-----------------------------------------------
void uart1_in_an (void)
{
if(!bRXIN1)return;
disableInterrupts();
bRXIN1=0;
if(strstr(uart1_an_buffer,"OK"))
{
bOK=1;
}
else if(strstr(uart1_an_buffer,"ERROR"))
{
bERROR=1;
}
else if(strstr(uart1_an_buffer,"UNDER-VOLTAGE WARNNING"))
{
//tree_up(iAfterReset,0,0,0);
//printf("AT + CPOWD = 1 \r");
//printf("AT + CBC \r");
modemDrvPowerDownStepCnt=1;
}
else if(strstr(uart1_an_buffer,"CBC"))
{
char* ptr1;
char* ptr2;
//char volatile ptr_temp[15];
ptr1=strstr(uart1_an_buffer,",");
ptr1++;
ptr2=strstr(ptr1,",");
ptr2++;
memset(cbc_temp,'\0',15);
memcpy(cbc_temp,ptr2,1);
memcpy(cbc_temp+1,".",1);
memcpy(cbc_temp+2,ptr2+1,3);
memset(cbc_temp1,'\0',15);
memcpy(cbc_temp1,ptr2,4);
cbcVoltage=(short)strtol(cbc_temp1,NULL,0);
//memset(cbc_temp,'\0',15);
//memcpy(cbc_temp,"7654",5);
if(cbcRequ)
{
sprintf(tempRussianText,"Напряжение аккумулятора %d,%03dв",cbcVoltage/1000,cbcVoltage%1000);
//sprintf(tempRussianText,"Напряжение аккумулятора %sв, система выключена до появления сети",ptr_temp);
modem_send_sms('p',MAIN_NUMBER,tempRussianText);
cbcRequ=0;
}
//printf(ptr_temp);
if(bCBC==1)bCBC=2;
if(bCBC_SELF==1)bCBC_SELF=2;
}
else if((strstr(uart1_an_buffer,"CUSD"))&&(ussdRequ))
{
char* ptr1;
char* ptr2;
ptr1=strstr(uart1_an_buffer,"\"");
ptr1++;
if((*(ptr1))=='0')
{
strncpy(tempRussianText,ptr1,80);
PDU2text(tempRussianText);
modem_send_sms('p',incommingNumberUSSDRequ,russianText);
}
else
{
ptr2=strstr(ptr1,"\"");
strncpy(tempRussianText,ptr1,/*(unsigned char)(ptr2-ptr1)*/40);
tempRussianText[40/*(unsigned char)(ptr2-ptr1)*/]=0;
modem_send_sms('p',incommingNumberUSSDRequ,tempRussianText);
}
if(ussdRequ)ussdRequ--;
}
else if(strstr(uart1_an_buffer,"+CMT"))
{
char volatile ptr_temp[15];
char volatile str_main_num[15];
char *ptrptr;
isFromMainNumberMess=0;
isFromAutorizedNumberMess=0;
isFromNotAutorizedNumberMess=0;
ptrptr=strstr(uart1_an_buffer,"+7");
memcpy(incommingNumber,ptrptr+2,10);
memset(ptr_temp,'\0',15);
memcpy(ptr_temp,&uart1_an_buffer[6],14);
memset(str_main_num,'\0',15);
memcpy(str_main_num,/*"9139294352"*/MAIN_NUMBER,10);
//if(strcmp(ptr_temp,str_main_num)==0)
if((strstr(incommingNumber,str_main_num)!=NULL)&&(AUTH_NUMBER_FLAGS&0x01))
{
//modem_plazma++;
isFromMainNumberMess=1;
}
memset(str_main_num,'\0',15);
memcpy(str_main_num,AUTH_NUMBER_1,10);
if((strstr(incommingNumber,str_main_num)!=NULL)&&(AUTH_NUMBER_FLAGS&0x02))
{
//modem_plazma++;
isFromAutorizedNumberMess=1;
}
memset(str_main_num,'\0',15);
memcpy(str_main_num,AUTH_NUMBER_2,10);
if((strstr(incommingNumber,str_main_num)!=NULL)&&(AUTH_NUMBER_FLAGS&0x04))
{
//modem_plazma++;
isFromAutorizedNumberMess=1;
}
memset(str_main_num,'\0',15);
memcpy(str_main_num,AUTH_NUMBER_3,10);
if((strstr(incommingNumber,str_main_num)!=NULL)&&(AUTH_NUMBER_FLAGS&0x08))
{
//modem_plazma++;
isFromAutorizedNumberMess=1;
}
if((isFromMainNumberMess==0)&&(isFromAutorizedNumberMess==0)) isFromNotAutorizedNumberMess=1;
}
else
{
//modem_plazma1++;
if((isFromMainNumberMess)||(isFromAutorizedNumberMess)||(isFromNotAutorizedNumberMess))
{
modem_plazma++;
PDU2text(uart1_an_buffer); //Пропускаем все пришедшие смс через парсер PDU
if(strstr(russianText,"НОМЕР ГЛАВНЫЙ")) //Установить главный номер
{
//modem_plazma1++;
memcpy(incommingNumberToMain,incommingNumber,10);
modem_send_sms('p',incommingNumber,"Отправьте в ответном смс 7 цифр выведенных на индикатор устройства");/**/
tree_up(iMn_number,0,0,0);
rand_dig[0]=(rand()%10);
rand_dig[1]=(rand()%10);
rand_dig[2]=(rand()%10);
rand_dig[3]=(rand()%10);
rand_dig[4]=(rand()%10);
rand_dig[5]=(rand()%10);
rand_dig[6]=(rand()%10);
sprintf(rand_dig_str,"%d%d%d%d%d%d%d",(int)rand_dig[0],(int)rand_dig[1],(int)rand_dig[2],(int)rand_dig[3],(int)rand_dig[4],(int)rand_dig[5],(int)rand_dig[6]);
ret_ind(120,0);
}
else if(strstr(uart1_an_buffer,rand_dig_str/*"1234576"*/))
{
if(memcmp(incommingNumber,incommingNumberToMain,10)==0)
{
memcpy(MAIN_NUMBER,incommingNumberToMain,10);
AUTH_NUMBER_FLAGS=0x01;
modem_send_sms('p',MAIN_NUMBER,"Ваш номер установлен как главный");
tree_down(0,0);
ind=iMn;
ret_ind(0,0);
HUMAN_SET_EE=1;
}
}
else if((strstr(russianText,"НОМЕР"))&&(isFromMainNumberMess)) //"Установить номер
{
number_temp=find_number_in_text(russianText);
if(number_temp)
{
if(find_this_number_in_autorized(number_temp))
{
modem_send_sms('p',MAIN_NUMBER,"Такой номер уже есть в списке авторизованых");
}
else if(find_empty_number_cell())
{
cell = find_empty_number_cell();
if(cell==1)
{
memcpy(AUTH_NUMBER_1,number_temp,10);
AUTH_NUMBER_FLAGS|=0b00000010;
HUMAN_SET_EE=1;
}
else if(cell==2)
{
memcpy(AUTH_NUMBER_2,number_temp,10);
AUTH_NUMBER_FLAGS|=0b00000100;
HUMAN_SET_EE=1;
}
else if(cell==3)
{
memcpy(AUTH_NUMBER_3,number_temp,10);
AUTH_NUMBER_FLAGS|=0b00001000;
HUMAN_SET_EE=1;
}
sprintf(tempRussianText,"Номер %s добавлен в список (ячейка %d)",number_temp,cell);
modem_send_sms('p',MAIN_NUMBER,tempRussianText);
sprintf(tempRussianText,"Ваш номер добавлен в список ");
modem_send_sms('p',number_temp,tempRussianText);
}
else
{
modem_send_sms('p',MAIN_NUMBER,"Номер не добавлен, память заполнена");
}
}
//modem_plazma1++;
//modem_send_sms('t',"9139294352",/*"OTPRAVTE 7 CIFR, VIVEDENNIH NA EKRAN USTROISTVA"*/"mama1");
}
else if((strstr(russianText,"СПИСОК"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Список телефонов
{
sprintf(tempRussianText,"Список:\n"); //номеров\n
//strcat(tempRussianText,"+7");
strncat(tempRussianText,MAIN_NUMBER,10);
strcat(tempRussianText," (гл.)\n");
//strcpy(tempRussianText,tempStr);
//sprintf(tempStr,"%s (главн),",MAIN_NUMBER);
//strcat(tempRussianText,tempStr);
if(AUTH_NUMBER_FLAGS&0x02)
{
//strcat(tempRussianText,",\r\n+7");
strncat(tempRussianText,AUTH_NUMBER_1,10);
strcat(tempRussianText," (1)\n");
}
if(AUTH_NUMBER_FLAGS&0x04)
{
//strcat(tempRussianText,",\r\n+7");
strncat(tempRussianText,AUTH_NUMBER_2,10);
strcat(tempRussianText," (2)\n");
}
if(AUTH_NUMBER_FLAGS&0x08)
{
//strcat(tempRussianText,",\r\n+7");
strncat(tempRussianText,AUTH_NUMBER_3,10);
strcat(tempRussianText," (3)");
}
modem_send_sms('p',incommingNumber,tempRussianText);
}
else if((strstr(russianText,"УДАЛИТЬ"))&&(isFromMainNumberMess)) //Удаление номеров
{
if(strstr(russianText,"ВСЕ"))
{
if(AUTH_NUMBER_FLAGS&0x0e)
{
AUTH_NUMBER_FLAGS&=0x01;
modem_send_sms('p',MAIN_NUMBER,"Все номера кроме главного удалены");
HUMAN_SET_EE=1;
}
else
{
modem_send_sms('p',MAIN_NUMBER,"В списке нет номеров кроме главного");
}
}
else if(find_number_in_text(russianText))
{
number_temp=find_number_in_text(russianText);
if(find_this_number_in_autorized(number_temp))
{
char temp=find_this_number_in_autorized(number_temp);
AUTH_NUMBER_FLAGS&=(char)(~(1<<temp));
strcpy(tempRussianText,"Номер ");
strncat(tempRussianText,number_temp,10);
strcat(tempRussianText," удален из списка номеров");
modem_send_sms('p',MAIN_NUMBER,tempRussianText);
HUMAN_SET_EE=1;
}
else modem_send_sms('p',MAIN_NUMBER,"Такого номера нет в списке");
}
}
else if((strstr(russianText,"УСТАВКИ"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //УСТАВКИ
{
if(MODE_EE==1)
{
sprintf(tempRussianText,"Режим - по воде\nуставка %dгр.\nмакс.мощность %d",(int)targetTemper,(int)MAX_POWER_EE);
}
if(MODE_EE==2)
{
sprintf(tempRussianText,"Режим - по воздуху\nуставка %dгр.\nмакс.мощность %d",(int)targetTemper,(int)MAX_POWER_EE);
}
if(MODE_EE==3)
{
sprintf(tempRussianText,"Режим - по графику\nтекущая уставка %dгр.(воздух)\nмакс.мощность %d",(int)targetTemper,(int)MAX_POWER_EE);
}
modem_send_sms('p',incommingNumber,tempRussianText);
}
else if((strstr(russianText,"РЕЖИМ"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Установка режима работы
{
if(strstr(russianText,"ВОДА"))
{
MODE_EE=1;
modem_send_sms('p',incommingNumber,"Установлен режим регулирования по температуре воды");
}
else if(strstr(russianText,"ВОЗДУХ"))
{
MODE_EE=2;
modem_send_sms('p',incommingNumber,"Установлен режим регулирования по температуре воздуха");
}
else
{
modem_send_sms('p',incommingNumber,"Команда не распознана");
}
//% modem_send_sms('p',incommingNumber,tempRussianText);
}
else if((strstr(russianText,"ВОДА"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Установка температуры воды
{
short tempSS=find_number_fild_in_text(russianText);
if(MODE_EE!=1)
{
modem_send_sms('p',incommingNumber,"В текущем режиме работы выполнение такой команды невозможно");
}
else if((tempSS<5)||(tempSS>85))
{
modem_send_sms('p',incommingNumber,"Значение находится за пределами разрешенных(5-85).Команда отклонена");
}
else
{
NECC_TEMPER_WATER_EE=tempSS;
sprintf(tempRussianText,"Температура воды установлена на %dгр.Ц.",(int)NECC_TEMPER_WATER_EE);
modem_send_sms('p',incommingNumber,tempRussianText);
HUMAN_SET_EE=1;
}
}
else if((strstr(russianText,"ВОЗДУХ"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Установка температуры воздуха
{
short tempSS=find_number_fild_in_text(russianText);
if(MODE_EE!=2)
{
modem_send_sms('p',incommingNumber,"В текущем режиме работы выполнение такой команды невозможно");
}
else if((tempSS<5)||(tempSS>35))
{
modem_send_sms('p',incommingNumber,"Значение находится за пределами разрешенных(5-35).Команда отклонена");
}
else
{
NECC_TEMPER_AIR_EE=tempSS;
sprintf(tempRussianText,"Температура воздуха установлена на %dгр.Ц.",(int)NECC_TEMPER_AIR_EE);
modem_send_sms('p',incommingNumber,tempRussianText);
HUMAN_SET_EE=1;
}
}
else if((strstr(russianText,"СТАТУС"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Запрос состояния системы
{
sprintf(tempStr,"Tвода %3dгр.Ц \n",(int)temperOfWater);
if(waterSensorErrorStat == dsesNORM)strcpy(tempRussianText,tempStr);
else strcpy(tempRussianText,"Tводы неиспр.\n");
sprintf(tempStr,"Tвоздух %3dгр.Ц \n",(int)temperOfAir);
if(airSensorErrorStat == taesNORM)strcat(tempRussianText,tempStr);
else strcat(tempRussianText,"Tвоздуха неиспр.\n");
if(powerAlarm == paNORM) strcat(tempRussianText,"Питание норма\n");
else strcat(tempRussianText,"Питание выкл.\n");
if(outMode==omON) strcat(tempRussianText,"Термостат вкл.\n");
else strcat(tempRussianText,"Термостат выкл.\n");
sprintf(tempStr,"Нагрев %1d",(int)powerEnabled);
strcat(tempRussianText,tempStr);
modem_send_sms('p',incommingNumber,tempRussianText);
}
else if((strstr(russianText,"ВЕРСИЯ"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Запрос версии прошивки
{
sprintf(tempRussianText,"Версия ПО %d.%03d",VERSION,BUILD);
modem_send_sms('p',incommingNumber,tempRussianText);
}
else if((strstr(uart1_an_buffer,"USSD"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Запрос версии прошивки
{
char* ppptr;
ppptr=strstr(uart1_an_buffer,"USSD");
ppptr+=4;
//sprintf(tempRussianText,"ATD%s\r\n",ppptr);AT+CUSD=1,"#100#"
sprintf(tempRussianText,"AT+CUSD=1,\"#100#\"\r\n",ppptr);//AT+CUSD=1,"#100#"
printf(tempRussianText);
//printf("ATD#100#;\r\n");
memcpy(incommingNumberUSSDRequ,incommingNumber,10);
ussdRequ=2;
}
else if((strstr(russianText,"АККУМУЛЯТОР"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Запрос состояния аккумулятора
{
printf("AT + CBC \r");
cbcRequ=1;
}
else if((strstr(russianText,"ОТЛАДКА"))&&(isFromMainNumberMess||isFromAutorizedNumberMess)) //Запрос версии прошивки
{
sprintf(tempRussianText,"Версия ПО %d.%03d",VERSION,BUILD);
modem_send_sms('p',incommingNumber,"Привет 0123456"/*tempRussianText*/);
}
isFromMainNumberMess=0;
isFromAutorizedNumberMess=0;
isFromNotAutorizedNumberMess=0;
}
}
enableInterrupts();
}
|
eeb099e3249b4ad18e44929a511aa7626a669943
|
bcded054246f8a29614d99d72921d04192bace13
|
/rubin/source/monitor/xwait.c
|
21cd926c8fbd603f2eada3cc2824bc3b06d4efb6
|
[] |
no_license
|
urras/DEMOS
|
3cc47bd13b88b927bbbc77033444d20f40824d69
|
c87ce5f748684b45995085ff9be34afc5174cf5c
|
refs/heads/master
| 2020-05-29T22:28:20.775045 | 2015-03-27T23:07:17 | 2015-03-27T23:07:17 | 33,014,836 | 5 | 2 | null | null | null | null |
UTF-8
|
C
| false | false | 925 |
c
|
xwait.c
|
# include "monitor.h"
# include <defines.h>
# include <aux.h>
# include <sccs.h>
SCCSID(@(#)xwait.c 7.1 2/5/81)
/*
** WAIT FOR PROCESS TO DIE
**
** Used in edit() and shell() to terminate the subprocess.
** Waits on pid "Xwaitpid". If this is zero, xwait() returns
** immediately.
**
** This is called by "catchsig()" so as to properly terminate
** on a rubout while in one of the subsystems.
**
** Trace Flags:
** 41
*/
xwait()
{
int status;
register int i;
register char c;
# ifdef xMTR2
if (tTf(41, 0))
printf("xwait: [%d]\n", Xwaitpid);
# endif
if (Xwaitpid == 0)
{
cgprompt();
return;
}
while ((i = wait(&status)) != -1)
{
# ifdef xMTR2
if (tTf(41, 1))
printf("pid %d stat %d\n", i, status);
# endif
if (i == Xwaitpid)
break;
}
Xwaitpid = 0;
/* reopen query buffer */
if ((Qryiop = fopen(Qbname, "a")) == NULL)
syserr("xwait: open %s", Qbname);
Notnull = 1;
cgprompt();
}
|
1f0a50fc3b7ecdd8c05a2a846ce73e5e5b0631c5
|
32831a8fa4c866e9029a77c0f774ce8cae2d0002
|
/ft_ls.c
|
e1cd01ef58972d729bbb8c3ed76728bcf9955614
|
[] |
no_license
|
haolgrek/ellaisse
|
d5932bee05f017dac9e345d808a7e9355c2031aa
|
cfa3e55d5b7857100cda18c5ef5fdb78d3547592
|
refs/heads/master
| 2021-01-10T11:33:25.233317 | 2016-03-03T16:31:33 | 2016-03-03T16:31:33 | 49,973,426 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,089 |
c
|
ft_ls.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ls.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rluder <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/01/21 19:45:38 by rluder #+# #+# */
/* Updated: 2016/03/03 14:17:46 by rluder ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_ls.h"
void get_options(char **argv, int j, int i, t_options *options)
{
if (argv[j][i] == 'l')
options->l = 1;
else if (argv[j][i] == 'R')
options->rec = 1;
else if (argv[j][i] == 'a')
options->a = 1;
else if (argv[j][i] == 'r')
options->r = 1;
else if (argv[j][i] == 't')
options->t = 1;
else if (argv[j][i] != '\0')
{
printf("ft_ls : illegal option -- %c\n", argv[j][i]);
printf("usage: ft_ls [-Ralrt] [file ...]\n");
exit(1);
}
options->nf = 0;
options->dir = 0;
}
int stock_options(char **argv, t_options *options)
{
int i;
int j;
j = 1;
while (argv[j] && argv[j][0] == '-' && argv[j][1])
{
if (argv[j][0] == '-')
{
i = 0;
while (argv[j][i] != '\0')
{
i++;
get_options(argv, j, i, options);
}
j++;
}
}
return (j);
}
void showlnk(t_data *data)
{
char buf[256];
int n;
n = readlink(data->path, (char*)&buf, 255);
write(1, buf, n);
}
char **argvpoint(int *argc)
{
char **argv;
*argc = 2;
argv = malloc(sizeof(char*) * 2);
argv[0] = ft_strdup("ft_ls");
argv[1] = ft_strdup(".");
argv[2] = NULL;
return (argv);
}
int ispoint(char *filename)
{
if (filename[0] == '.')
return (1);
return (0);
}
|
bf3c5c29c0003d6bd2876b3a4e0ad288445013ea
|
e3a97b316fdf07b170341da206163a865f9e812c
|
/arrows/ffmpeg/ffmpeg_init.h
|
54fcf12a3a9c48d2b4cb794040136aa47cac4e15
|
[
"BSD-3-Clause"
] |
permissive
|
Kitware/kwiver
|
09133ede9d05c33212839cc29d396aa8ca21baaf
|
a422409b83f78f31cda486e448e8009513e75427
|
refs/heads/master
| 2023-08-28T10:41:58.077148 | 2023-07-28T21:18:52 | 2023-07-28T21:18:52 | 23,229,909 | 191 | 92 |
NOASSERTION
| 2023-06-26T17:18:20 | 2014-08-22T15:22:20 |
C++
|
UTF-8
|
C
| false | false | 541 |
h
|
ffmpeg_init.h
|
// This file is part of KWIVER, and is distributed under the
// OSI-approved BSD 3-Clause License. See top-level LICENSE file or
// https://github.com/Kitware/kwiver/blob/master/LICENSE for details.
#ifndef FFMPEG_INIT_H_
#define FFMPEG_INIT_H_
/// @brief Initialize the ffmpeg codecs.
///
/// This will be called by the ffmpeg streams, so you shouldn't need to worry
/// about it. This function can be called multiple times, but the real ffmpeg
/// initialization routine will run only once.
void ffmpeg_init();
#endif // FFMPEG_INIT_H_
|
fb79c6ad32beb61a40382deafe1b9cc0d4ac606e
|
43d23c4b89267ba05a21f8d1209d0fad88efa1a0
|
/libft/src/str/ft_atoi.c
|
aeae2352cd2daaaf9d022a7b0eade1da18b3b1d9
|
[] |
no_license
|
vrilly/cub3D
|
5f97b287423af4e056d44f35efd6935dcc5881e9
|
485bdfd90289542240842c73e111182e5f5651d9
|
refs/heads/master
| 2022-10-13T14:16:37.813663 | 2020-06-08T14:07:09 | 2020-06-08T14:07:09 | 232,843,529 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,357 |
c
|
ft_atoi.c
|
/* ************************************************************************** */
/* */
/* :::::::: */
/* atoi.c :+: :+: */
/* +:+ */
/* By: tjans <[email protected]> +#+ */
/* +#+ */
/* Created: 2019/10/29 14:15:01 by tjans #+# #+# */
/* Updated: 2019/11/22 19:39:20 by tjans ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
int ft_atoi(const char *str)
{
long result;
int negative;
result = 0;
while ((*str == ' ' || *str == '\t' || *str == '\r' ||
*str == '\n' || *str == '\v' || *str == '\f') && *str)
str++;
negative = (*str == '-');
if (*str == '-' || *str == '+')
str++;
while (*str)
{
if (*str < '0' || *str > '9')
break ;
result *= 10;
result += (int)*str - '0';
str++;
}
if (negative)
return (result * -1);
return (result);
}
|
7cff8ec1cd745ba6b6e2c62da51954eecb1871e9
|
1bbc6bc4ef8e10a8f52cea11470fd08892848446
|
/cLibrary/ABS.C
|
90518588a90af6c1675d5368e4b139f16ad557e5
|
[] |
no_license
|
yeonseo/AndroidWebAppEdu
|
8b826c49b2e3ef4e48d72860824d82c901037261
|
f38ba2ee4a1135ee9ac3dca7fc0b55929b784e0d
|
refs/heads/master
| 2022-04-18T00:10:19.959584 | 2020-03-12T06:21:40 | 2020-03-12T06:21:40 | 194,628,540 | 3 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 121 |
c
|
ABS.C
|
#include <stdio.h>
#include <math.h>
void main()
{
int i=-256;
printf("i is %d\n",i);
printf("abs(i) is %d\n",abs(i));
}
|
32db01dd803e0335adf5357eebf5208a8c30bbb8
|
8dd61530024fc5bf045cac5cad5cef5df25f1cfe
|
/An I/Programare Procedurala/Lab6ProceduralaProb5.c
|
6beaa40394cb96fda51596693b8e6ae2ef71c60f
|
[] |
no_license
|
SeverinDragos/Universitate
|
b91dedf518b23d6d39ccbc0952444f75bed6904a
|
1201a0614fc66ff5d173fdd4c2fcd5233b8f1ce2
|
refs/heads/master
| 2020-04-27T21:29:12.608114 | 2019-03-09T13:41:49 | 2019-03-09T13:41:49 | 174,698,761 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,547 |
c
|
Lab6ProceduralaProb5.c
|
#include <stdio.h>
#include <stdlib.h>
struct Complex
{
int Rez,Imz;
void (*pfAfis)(struct Complex);
void (*pfCitire)(struct Complex*);
}v[100];
void Afisare(struct Complex x)
{
printf("Rez: %d Imz: %d ",x.Rez,x.Imz);
}
void Citire(struct Complex *x)
{
printf("Partea reala si apoi imaginara a numarului:");
scanf("%d%d",&x->Rez,&x->Imz);
}
struct Complex AdunareComplexe(int n)
{
struct Complex rezultat;
int i;
rezultat.Rez=0;
rezultat.Imz=0;
for(i=0;i<n;i++)
{
rezultat.Rez+=v[i].Rez;
rezultat.Imz+=v[i].Imz;
}
return rezultat;
}
struct Complex InmultireComplexe(int n)
{
struct Complex rezultat;
int i,Re=0,Im=0;
rezultat.Rez=v[0].Rez;
rezultat.Imz=v[0].Imz;
for(i=1;i<n;i++)
{
Re = (rezultat.Rez) * (v[i].Rez) - (rezultat.Imz) * (v[i].Imz);
Im = (rezultat.Rez) * (v[i].Imz) + (v[i].Rez) * (rezultat.Imz);
rezultat.Rez=Re;
rezultat.Imz=Im;
}
return rezultat;
}
int main()
{
int n,i;
printf("Numarul de numere complexe:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
v[i].pfCitire=&Citire;
v[i].pfCitire(&v[i]);
}
printf("Suma celor %d numere este:",n);
struct Complex a;
struct Complex (*pf)(int);
pf=AdunareComplexe;
a=(*pf)(n);
a.pfAfis=Afisare;
a.pfAfis(a);
printf("\nProdusul celor %d numere este:",n);
struct Complex b;
struct Complex (*pf2)(int);
pf2=InmultireComplexe;
b=(*pf2)(n);
b.pfAfis=Afisare;
b.pfAfis(b);
return 0;
}
|
d8e2270a2ad83b6ad146cce9badeaa4b5121f818
|
f5c85cfe53d53c0e32ce79fbdf643aee2406c98f
|
/washere.c
|
07ccde3cc4480b412d69a2b855286d028d229a6c
|
[] |
no_license
|
MitchH442/ELET-1102
|
f9d4e7f2fa5096eb4f9b36ec1decd30b7c0036fc
|
6cfd3a29f14f0f7e4cad3b31ccb00c52ac50df3c
|
refs/heads/main
| 2023-01-08T02:48:49.510909 | 2020-11-12T18:11:18 | 2020-11-12T18:11:18 | 309,771,474 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 102 |
c
|
washere.c
|
#include <stdio.h>
int main()
{
printf("Mitch Was here! 11/12/2020 801005411");
return 0;
}
|
a3a8727795a07df93063638cc3921f42191203a9
|
8bf5418d9afa10b0113f2fde75fa748c055413b3
|
/net_httpclient.c
|
648517cbd5b8acc27149a90349e9ed2ab9f159c1
|
[
"MIT"
] |
permissive
|
funlibs/net
|
1c350f7622da91b3af80c94da3f4ac3fe9174c66
|
501eb4855fd91966d7db3c1d4cb3be767d35a13a
|
refs/heads/master
| 2021-01-21T10:25:31.956078 | 2017-03-07T12:33:07 | 2017-03-07T12:33:07 | 83,422,588 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,250 |
c
|
net_httpclient.c
|
/*
* File: net_http_client.c
* Author: Sébastien Serre <sserre at msha.fr>
*
* Created on 27 février 2017, 16:58
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <net.h>
char HTTP_GET[] =
"GET / HTTP/1.0\r\n"
"Host: %s\r\n\r\n";
#define PAYLOAD_MAX 100000
#define REQUEST_MAX 100000
/*
*
* Usage:
* net_example ssl www.example.com
* net_example nossl www.example.com
*/
int
main(int argc, char** argv) {
int count, port, opts;
char payload[PAYLOAD_MAX + 1], request[REQUEST_MAX + 1];
NetSocket socket;
if (argc < 3) {
printf("no enought args");
return (EXIT_FAILURE);
}
port = 80;
opts = NET_TCP;
if (strcmp(argv[1], "ssl") == 0) {
port = 443;
opts = NET_TCP | NET_SSL;
}
socket = netDial(argv[2], port, opts);
if (socket.fd < 0) {
printf("ERROR: %s\n", netGetStatus(socket));
return (EXIT_FAILURE);
}
snprintf(request, REQUEST_MAX, HTTP_GET, argv[2]);
if (netWrite(socket, request, strlen(request)) >= 0) {
while ((count = netRead(socket, payload, PAYLOAD_MAX)) > 0) {
printf("%s", payload);
}
}
netClose(socket);
return (EXIT_SUCCESS);
}
|
d9390a091b79810ed9f7b54582c3417d89de3241
|
b9c978b7decfd201b61e2734290d9bb160c9c8c9
|
/RPI.h
|
0bf51aa4133701c1cdfcc9bf316da8646b545bc3
|
[] |
no_license
|
JBas/RPi_LLP
|
76112abd836f0eff4b35a56f1bc575e676a8fa45
|
fb293c7cc3b36c1789268fb811b7935a4b21a634
|
refs/heads/master
| 2021-09-06T02:38:10.333645 | 2018-02-01T19:24:44 | 2018-02-01T19:24:44 | 119,867,513 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,227 |
h
|
RPI.h
|
#include <stdio.h>
// memory management library
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define BCM2708_PERI_BASE 0x20000000
// offset into the GPIO address space (pg. 90)
#define GPIO_BASE (BCM2708_PERI_BASE + 0x200000)
// @TODO: figure out what this is for
#define BLOCK_SIZE (4*1024)
// GPIO setup macros. Always use INP_GPIO(x) before using OUT_GPIO(x)
#define INP_GPIO(g) *(gpio.addr + (g/10)) &= ~(7 << ((g%10) * 3))
#define OUT_GPIO(g) *(gpio.addr + (g/10)) |= (1 << ((g%10) * 3))
#define SET_GPIO_ALT(g, a) *(gpio.addr + (g/10)) |= (((a) <= 3 ? (a) + 4 : (a) == 4 ? 3 : 2) << (((g)%10) * 3))
#define GPIO_SET *(gpio.addr + 7) // sets bits that are 1, ignores those that are 0
#define GPIO_CLR *(gpio.addr + 10) // sets clears bits which are 1, ignore those that are 0
#define GPIO_READ(g) *(gpio.addr + 13) &= (1 << g)
// IO Access
struct bcm2835_peripheral_header {
unsigned ling addr_p;
int mem_fd;
void *map;
volatile unsigned int *addr;
}; typedef bcm2835_peripheral
bcm2835_peripheral gpio = {GPIO_BASE};
extern bcm2835_peripheral gpio; // for files that need gpio variable
|
7ac94d38adf5088951c5257bd6894074dd027b06
|
4a82885b8d642fd3e665645e3ad40e5e97983b38
|
/udp_bc/src/udp_bc.c
|
7bc0c5ec28d6f84bdbd5bab27ac2a5bc4f0cfe8a
|
[
"Apache-2.0"
] |
permissive
|
lingfliu/smart_tuwa
|
fc4c1730566e26807ecbe600e9dc25c2c71ad678
|
6dc4bcfe7ee72828e1bc34269413d8596ea65acd
|
refs/heads/master
| 2021-01-17T13:30:01.406036 | 2017-05-25T08:57:34 | 2017-05-25T08:57:34 | 28,345,414 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,306 |
c
|
udp_bc.c
|
#include "udp_bc.h"
int main(int argn, char* argv[]){
/********************************************
1. udp bc thread
********************************************/
struct sockaddr_in bcaddr;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock == -1){
return -1;
}
int bcEnabled = 1;
retval = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char*) &bcEnabled, sizeof(bcEnabled));
memset(&bcaddr, 0, sizeof(bcaddr));
bcaddr.sin_family = AF_INET;
bcaddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
bcaddr.sin_port = htons(BC_PORT);
if(inet_pton(AF_INET, BC_ADDR, (void*) &bcaddr.sin_addr)<= 0){
return -1;
}
//initialize system periodic task
gettimeofday(&timer, NULL);
int pos = 0;
char* content = "TWRT-IP-BROADCAST";
int ret = 0;
while(1){
sleep(3);
ret = sendto(sock, content, strlen(content), 0, (struct sockaddr*) &bcaddr, sizeof(bcaddr));
if (ret<0){
printf("broadcast failed\n");
}
else {
printf("broadcast send %d bytes\n", ret);
}
/*
while(pos < 4){
ret = send(sock, content+pos, 4-pos, MSG_NOSIGNAL);
if (ret == 4 - pos){
printf("Send broadcast\n");
pos = 0;
}
else if (ret <= 0){
printf("Send broadcast failed\n");
pos = 0;
}
else {
printf("Send partial\n");
pos += ret;
}
}
*/
}
}
|
90b10adca02c4f0435c66aa55addad390fb0fa91
|
e3702676489788ae33c14c93190812f0b0a26601
|
/2021study/1_7_study/1_7_study/test.c
|
09dd12b392647adb95005f92c8727b0a250ab8ef
|
[] |
no_license
|
zykgithub1/blackcode
|
03ff5e30f9432bb39b032bc43a5223a642ce2f3c
|
31cb41cf1d0701842cb87ef2586af96935b8ec8e
|
refs/heads/master
| 2023-03-04T21:44:45.484555 | 2021-02-19T15:23:41 | 2021-02-19T15:23:41 | 318,055,873 | 0 | 0 | null | null | null | null |
GB18030
|
C
| false | false | 805 |
c
|
test.c
|
#include <stdio.h>
//1,最原始版本
//int check_sys(){
// int a = 1;
// char* p = (char*)&a;
// if (1 == *p){
// return *p;
// }
// else{
// return 0;
// }
//}
//版本2:
//int check_sys(){
// int a = 1;
// char*p=(char*)&a;
// return *p;
//}
//版本3:
//
//int check_sys(){
// int a = 1;
// return *(char*)&a;
//}
//
//int main()
//{
// //写一段代码,获得当前数据的字节序
// int ret=check_sys();
// if (ret == 1){
// printf("小端\n");
// }else{
// printf("大端\n");
// }
// return 0;
//}
//int main()
//{
// int a = 0x11223344;
// //int* p = &a;
// //*p = 0;
// char *p = &a;
// *p = 0;
// return 0;
//}
int main()
{
char a = -1;
signed char b = -1;
unsigned char c = -1;
printf("%d ,%d,%d", a, b, c);
return 0;
}
|
94dac9c07d2e860afe01d3763702adbdfa17d2e9
|
07926ae91fe78d850b8db916163934d1d6333371
|
/datastructure/linkedlist/get-the-value-of-the-node-at-a-specific-position-from-the-tail.c
|
be9857f8f99cb6d3dd0b54102536012fe42a26e6
|
[] |
no_license
|
wllmnc/hackerRank
|
a3ec8e7866474788944c765eb61cf18c714fa57b
|
410bc5a2fd0139052e8180abf897ba89ecec09fa
|
refs/heads/master
| 2021-10-22T14:04:52.181345 | 2021-10-11T05:46:58 | 2021-10-11T05:46:58 | 57,273,948 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 709 |
c
|
get-the-value-of-the-node-at-a-specific-position-from-the-tail.c
|
//https://www.hackerrank.com/challenges/get-the-value-of-the-node-at-a-specific-position-from-the-tail
/*
Get Nth element from the end in a linked list of integers
Number of elements in the list will always be greater than N.
Node is defined as
struct Node
{
int data;
struct Node *next;
}
*/
int GetNode(Node *head,int positionFromTail)
{
// This is a "method-only" submission.
// You only need to complete this method.
Node * current=head;
int lenght=0;
while(current!=NULL)
{
lenght++;
current=current->next;
}
current=head;
int cont=1;
while(cont<lenght-positionFromTail)
{
cont++;
current=current->next;
}
return current->data;
}
|
37d7a9a9926d7c0cc29ac61763f05f8c6da15984
|
783f93a65c7070d76aa63a0704f05173c7d199b3
|
/target/source/net/smng/fte_smng.c
|
026db1c17a48d0acde22c6a951f806cffbdc358e
|
[] |
no_license
|
futuretekinc/fte
|
a3ef852d06fbf9d00855d51e5e2dd49a21d13b67
|
cb5ab49e86e2b5a47cbcd009e801dfdc95dc06db
|
refs/heads/master
| 2021-06-19T22:18:35.100106 | 2017-07-21T05:44:08 | 2017-07-21T05:44:08 | 36,979,442 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 12,282 |
c
|
fte_smng.c
|
#include "fte_target.h"
#include "fte_net.h"
#include "fte_task.h"
#include "fte_config.h"
#include "fte_sys_bl.h"
#include "fte_time.h"
#include <rtcs.h>
#undef __MODULE__
#define __MODULE__ FTE_MODULE_NET_SMNG
#define FTE_SMNG_MSG_TYPE_DISCOVERY 0x01
#define FTE_SMNG_MSG_TYPE_DISCOVERY_WITH_TRAPS 0x02
#define FTE_SMNG_MSG_TYPE_RESET 0x03
#define FTE_SMNG_MSG_TYPE_UPGRADE 0x04
typedef struct
{
FTE_UINT32 nMsgType;
} FTE_SMNG_PACKET, _PTR_ FTE_SMNG_PACKET_PTR;
static FTE_CHAR_PTR pDiscoveryMsg = NULL;
void FTE_SMNG_task(pointer pParams, pointer pCreator)
{
FTE_CHAR _pBuff[1024];
FTE_UINT32 hSock = socket(PF_INET, SOCK_DGRAM, 0);
FTE_UINT32 bOption;
sockaddr_in xAnyAddr, xRecvAddr;
FTE_UINT16 nRecvAddrLen;
FTE_UINT32 nLen;
_ip_address xLastRequestHost;
TIME_STRUCT xLastResponseTime;
xAnyAddr.sin_family = AF_INET;
xAnyAddr.sin_port = FTE_NET_SMNG_PORT;
xAnyAddr.sin_addr.s_addr = INADDR_ANY;
if (hSock == RTCS_SOCKET_ERROR)
{
RTCS_task_exit(pCreator, RTCSERR_OUT_OF_SOCKETS);
}
/* Begin ENGR00243356 */
/* Set socket options to no wait */
bOption = TRUE;
setsockopt(hSock, SOL_UDP, OPT_SEND_NOWAIT, &bOption, sizeof(bOption));
/* End ENGR00243356 */
bind(hSock, &xAnyAddr, sizeof(xAnyAddr));
nRecvAddrLen = sizeof(xRecvAddr);
memset(&xRecvAddr, 0, nRecvAddrLen);
RTCS_task_resume_creator(pCreator, RTCS_OK);
FTE_TASK_append(FTE_TASK_TYPE_RTCS, _task_get_id());
_time_get(&xLastResponseTime);
while(1)
{
FTE_UINT32 nMsgType;
memset(_pBuff, 0, sizeof(_pBuff));
nLen = recvfrom(hSock, _pBuff, sizeof(_pBuff), 0, &xRecvAddr, &nRecvAddrLen);
if (nLen <= 0)
{
continue;
}
FTE_NET_liveTouch();
if (strcmp(_pBuff, "Hello?") == 0)
{
nMsgType = FTE_SMNG_MSG_TYPE_DISCOVERY_WITH_TRAPS;
}
else if (strcmp(_pBuff, "Reset") == 0)
{
nMsgType = FTE_SMNG_MSG_TYPE_RESET;
}
else if (strcmp(_pBuff, "Upgrade") == 0)
{
nMsgType = FTE_SMNG_MSG_TYPE_UPGRADE;
}
else
{
nMsgType = ntohl(&((FTE_SMNG_PACKET_PTR)_pBuff)->nMsgType);
}
switch(nMsgType)
{
case FTE_SMNG_MSG_TYPE_DISCOVERY_WITH_TRAPS:
{
TIME_STRUCT xCurrentTime;
FTE_INT32 nDiffTime;
_time_get(&xCurrentTime);
FTE_TIME_diff(&xCurrentTime, &xLastResponseTime, &nDiffTime);
if ((xLastRequestHost != xRecvAddr.sin_addr.s_addr) || ( nDiffTime > 10))
{
#if FTE_SNMPD_SUPPORTED
FTE_SNMPD_TRAP_discovery(xRecvAddr.sin_addr.s_addr);
xLastResponseTime = xCurrentTime;
xLastRequestHost = xRecvAddr.sin_addr.s_addr;
#endif
}
}
break;
case FTE_SMNG_MSG_TYPE_RESET:
{
_time_delay(1000);
FTE_SYS_reset();
}
break;
case FTE_SMNG_MSG_TYPE_UPGRADE:
{
_time_delay(1000);
FTE_SYS_BL_startUpgrade();
}
break;
}
}
}
FTE_RET FTE_SMNGD_init
(
FTE_VOID_PTR pParams
)
{
TRACE_ON();
#if 0
FTE_NET_CFG_PTR pCfgNet = FTE_CFG_NET_get();
FTE_JSON_VALUE_PTR pObject;
FTE_JSON_VALUE_PTR pValue;
FTE_JSON_VALUE_PTR pOIDs;
_enet_address xMACAddress;
FTE_CHAR pMACString[20];
FTE_UINT32 ulMsgLen;
pObject = FTE_JSON_VALUE_createObject(3);
if (pObject == NULL)
{
return FTE_RET_ERROR;
}
pValue = FTE_JSON_VALUE_createString(FTE_SYS_getOIDString());
FTE_JSON_OBJECT_setPair((FTE_JSON_OBJECT_PTR)pObject, "id", pValue);
FTE_SYS_getMAC(xMACAddress);
snprintf(pMACString, sizeof(pMACString), "%02x:%02x:%02x:%02x:%02x:%02x",
xMACAddress[0], xMACAddress[1],
xMACAddress[2], xMACAddress[3],
xMACAddress[4], xMACAddress[5]);
pValue = FTE_JSON_VALUE_createString(pMACString);
FTE_JSON_OBJECT_setPair((FTE_JSON_OBJECT_PTR)pObject, "mac", pValue);
pOIDs = FTE_JSON_VALUE_createArray(FTE_OBJ_DESC_CLASS_count());
for(FTE_UINT32 i = 0 ; i < FTE_OBJ_DESC_CLASS_count() ; i++)
{
FTE_CHAR pOID[32];
FTE_UINT32 ulClass = FTE_OBJ_DESC_CLASS_getAt(i);
if (ulClass != 0)
{
sprintf(pOID, "%d", ulClass >> 16);
pValue = FTE_JSON_VALUE_createString(pOID);
if (pValue != NULL)
{
FTE_JSON_ARRAY_setElement((FTE_JSON_ARRAY_PTR)pOIDs, pValue);
}
}
}
FTE_JSON_OBJECT_setPair((FTE_JSON_OBJECT_PTR)pObject, "oids", pOIDs);
ulMsgLen = FTE_JSON_VALUE_buffSize(pObject) + 1;
pDiscoveryMsg = (FTE_CHAR_PTR)FTE_MEM_alloc(ulMsgLen);
if (pDiscoveryMsg == NULL)
{
ERROR("Not enough memory!\n");
FTE_SYS_setUnstable();
return FTE_RET_ERROR;
}
FTE_JSON_VALUE_snprint(pDiscoveryMsg, ulMsgLen, pObject);
FTE_JSON_VALUE_destroy(pObject);
#endif
return RTCS_task_create("smng", FTE_NET_SMNG_PRIO, FTE_NET_SMNG_STACK, FTE_SMNG_task, NULL);
}
FTE_RET FTE_SMNG_getDiscoveryMessage
(
FTE_CHAR_PTR pBuff,
FTE_UINT32 ulBuffSize
)
{
ASSERT(pBuff != NULL);
if (pDiscoveryMsg == NULL)
{
FTE_RET xRet;
FTE_NET_CFG_PTR pCfgNet;
FTE_JSON_VALUE_PTR pObject;
FTE_JSON_VALUE_PTR pValue;
FTE_JSON_VALUE_PTR pOIDs;
_enet_address xMACAddress;
FTE_CHAR pMACString[20];
FTE_CHAR pIPString[20];
FTE_UINT32 ulMsgLen;
IPCFG_IP_ADDRESS_DATA xIPData;
xRet = FTE_CFG_NET_get(&pCfgNet);
if (xRet != FTE_RET_OK)
{
pBuff[0] = '\0';
return xRet;
}
pObject = FTE_JSON_VALUE_createObject(4);
if (pObject == NULL)
{
pBuff[0] = '\0';
return FTE_RET_NOT_ENOUGH_MEMORY;
}
pValue = FTE_JSON_VALUE_createString(FTE_SYS_getOIDString());
FTE_JSON_OBJECT_setPair((FTE_JSON_OBJECT_PTR)pObject, "id", pValue);
FTE_SYS_getMAC(xMACAddress);
snprintf(pMACString, sizeof(pMACString), "%02x:%02x:%02x:%02x:%02x:%02x",
xMACAddress[0], xMACAddress[1],
xMACAddress[2], xMACAddress[3],
xMACAddress[4], xMACAddress[5]);
pValue = FTE_JSON_VALUE_createString(pMACString);
FTE_JSON_OBJECT_setPair((FTE_JSON_OBJECT_PTR)pObject, "mac", pValue);
ipcfg_get_ip (BSP_DEFAULT_ENET_DEVICE, &xIPData);
snprintf(pIPString, sizeof(pIPString), "%d.%d.%d.%d", IPBYTES(xIPData.ip));
pValue = FTE_JSON_VALUE_createString(pIPString);
FTE_JSON_OBJECT_setPair((FTE_JSON_OBJECT_PTR)pObject, "ip", pValue);
pOIDs = FTE_JSON_VALUE_createArray(FTE_OBJ_DESC_CLASS_count());
for(FTE_UINT32 i = 0 ; i < FTE_OBJ_DESC_CLASS_count() ; i++)
{
FTE_CHAR pOID[32];
FTE_UINT32 ulClass = FTE_OBJ_DESC_CLASS_getAt(i);
if (ulClass != 0)
{
sprintf(pOID, "%d", ulClass >> 16);
pValue = FTE_JSON_VALUE_createString(pOID);
if (pValue != NULL)
{
FTE_JSON_ARRAY_setElement((FTE_JSON_ARRAY_PTR)pOIDs, pValue);
}
}
}
FTE_JSON_OBJECT_setPair((FTE_JSON_OBJECT_PTR)pObject, "oids", pOIDs);
ulMsgLen = FTE_JSON_VALUE_buffSize(pObject) + 1;
pDiscoveryMsg = (FTE_CHAR_PTR)FTE_MEM_alloc(ulMsgLen);
if (pDiscoveryMsg == NULL)
{
ERROR("Not enough memory!\n");
FTE_SYS_setUnstable();
return FTE_RET_NOT_ENOUGH_MEMORY;
}
FTE_JSON_VALUE_snprint(pDiscoveryMsg, ulMsgLen, pObject);
FTE_JSON_VALUE_destroy(pObject);
}
strncpy(pBuff, pDiscoveryMsg, ulBuffSize);
return FTE_RET_OK;
}
/******************************************************************************
* Shell command
******************************************************************************/
FTE_INT32 FTE_SMNGD_SHELL_cmd
(
FTE_INT32 nArgc,
FTE_CHAR_PTR pArgv[]
)
{
FTE_BOOL bPrintUsage, bShortHelp = FALSE;
FTE_INT32 xRet = SHELL_EXIT_SUCCESS;
bPrintUsage = Shell_check_help_request(nArgc, pArgv, &bShortHelp );
if (!bPrintUsage)
{
switch(nArgc)
{
case 3:
{
if (strcmp(pArgv[1], "class") == 0)
{
if (strcmp(pArgv[2], "list") == 0)
{
FTE_UINT32 i,j, ulCount;
FTE_UINT32 pulClassIDs[16];
ulCount = FTE_OBJ_DESC_CLASS_count();
for(i = 0 ; i < ulCount ; i++)
{
pulClassIDs[i] = FTE_OBJ_DESC_CLASS_getAt(i);
}
for(i = 0 ; i < ulCount - 1 ; i++)
{
for(j = i+1 ; j < ulCount ; j++)
{
if (pulClassIDs[i] > pulClassIDs[j])
{
FTE_UINT32 ulTemp = pulClassIDs[i];
pulClassIDs[i] = pulClassIDs[j];
pulClassIDs[j] = ulTemp;
}
}
}
for(i = 0 ; i < ulCount ; i++)
{
FTE_UINT32 ulClass = pulClassIDs[i];
FTE_CHAR pClassName[32];
FTE_OBJ_CLASS_getName(ulClass, pClassName, sizeof(pClassName));
printf("%d : %6d %s\n", i + 1, ulClass >> 16, pClassName);
}
}
}
}
break;
case 4:
{
if (strcmp(pArgv[1], "class") == 0)
{
if (strcmp(pArgv[2], "hide") == 0)
{
FTE_UINT32 ulClass;
if (FTE_strToHex(pArgv[3], &ulClass) != FTE_RET_OK)
{
printf("Invalid Class ID[%s]\n", pArgv[3]);
xRet = SHELL_EXIT_ERROR;
break;
}
}
}
}
break;
default:
bPrintUsage = TRUE;
goto error;
}
}
error:
if (bPrintUsage)
{
if (bShortHelp)
{
printf("%s <command>\n", pArgv[0]);
}
else
{
printf("Usage: %s <command>\n",pArgv[0]);
printf(" Commands:\n");
printf(" class list\n");
printf(" Supported object type list\n");
}
}
return xRet;
} /* Endbody */
|
29e017c1f7e0592485a6ae2c04db876654d00341
|
d3df607281e2aee0899a72c99d9b253c2550dbfd
|
/project/src/hw/driver/src/sjk_uart.c
|
0b1164f30963490e642ef6e9208e09a6f9d5340c
|
[] |
no_license
|
KKKKpossible/DigitalFront_2
|
51783663cc625564931a09feb0810cc9f14a2073
|
cceecd2edc3a45404503884f67e0ecd5ed3a6e45
|
refs/heads/main
| 2023-04-25T09:06:53.255595 | 2021-05-20T03:19:42 | 2021-05-20T03:19:42 | 357,363,986 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 10,517 |
c
|
sjk_uart.c
|
/*
* uart.c
*
* Created on: 2021. 4. 13.
* Author: sungjinkim
*/
#include "sjk_uart.h"
#define UART_INTERRUPT_LENGTH_MAX (1U)
Uart_t uart_arr[HW_UART_CHANNEL_MAX];
UART_HandleTypeDef huart1;
HAL_StatusTypeDef uart_status;
DMA_HandleTypeDef hdma_usart1_rx;
static bool SjkUartInit (uint8_t ch);
static bool AutoUartInit (void);
bool UartInit(uint8_t ch)
{
bool ret = true;
AutoUartInit();
SjkUartInit(ch);
return ret;
}
void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(uartHandle->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspInit 0 */
/* USER CODE END USART1_MspInit 0 */
/* USART1 clock enable */
__HAL_RCC_USART1_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/**USART1 GPIO Configuration
PA9 ------> USART1_TX
PA10 ------> USART1_RX
*/
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* USART1 DMA Init */
/* USART1_RX Init */
hdma_usart1_rx.Instance = DMA1_Channel5;
hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart1_rx.Init.Mode = DMA_NORMAL;
hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;
if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK)
{
Error_Handler();
}
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart1_rx);
/* USART1 interrupt Init */
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspInit 1 */
/* USER CODE END USART1_MspInit 1 */
}
}
void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
{
if(uartHandle->Instance==USART1)
{
/* USER CODE BEGIN USART1_MspDeInit 0 */
/* USER CODE END USART1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART1_CLK_DISABLE();
/**USART1 GPIO Configuration
PA9 ------> USART1_TX
PA10 ------> USART1_RX
*/
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
/* USART1 DMA DeInit */
HAL_DMA_DeInit(uartHandle->hdmarx);
/* USART1 interrupt Deinit */
HAL_NVIC_DisableIRQ(USART1_IRQn);
/* USER CODE BEGIN USART1_MspDeInit 1 */
/* USER CODE END USART1_MspDeInit 1 */
}
}
bool UartWriteTxBuffer(uint8_t ch, uint8_t* data, uint16_t length)
{
bool ret = true;
switch(ch)
{
case DEF_UART_CHANNEL_0:
for(int i = 0; i < length; i++)
{
if(UartIsFullTxBuffer(ch) != true)
{
uart_arr[ch].tx_buffer[uart_arr[ch].tx_header] = data[i];
uart_arr[ch].tx_header = (uart_arr[ch].tx_header + 1) % UART_BUFFER_LENGTH;
}
else
{
ret = false;
break;
}
}
break;
default:
break;
}
return ret;
}
bool UartIsEmptyTxBuffer(uint8_t ch)
{
bool ret = true;
switch(ch)
{
case DEF_UART_CHANNEL_0:
if(uart_arr[ch].tx_header != uart_arr[ch].tx_tail)
{
ret = false;
}
break;
default:
break;
}
return ret;
}
bool UartIsFullTxBuffer(uint8_t ch)
{
bool ret = true;
switch(ch)
{
case DEF_UART_CHANNEL_0:
if((uart_arr[ch].tx_header + 1) % UART_BUFFER_LENGTH != uart_arr[ch].tx_tail)
{
ret = false;
}
break;
default:
break;
}
return ret;
}
bool UartIsEmptyRxBuffer(uint8_t ch)
{
bool ret = true;
switch(ch)
{
case DEF_UART_CHANNEL_0:
if(uart_arr[ch].rx_header != uart_arr[ch].rx_tail)
{
ret = false;
}
break;
default:
break;
}
return ret;
}
bool UartIsFullRxBuffer(uint8_t ch)
{
bool ret = true;
switch(ch)
{
case DEF_UART_CHANNEL_0:
if((uart_arr[ch].rx_header + 1) % UART_BUFFER_LENGTH != uart_arr[ch].rx_tail)
{
ret = false;
}
break;
default:
break;
}
return ret;
}
uint8_t UartReadRxBuffer(uint8_t ch)
{
uint8_t ret = '\0';
switch(ch)
{
case DEF_UART_CHANNEL_0:
if(UartRxAvailable(ch) != 0)
{
ret = uart_arr[ch].rx_buffer[uart_arr[ch].rx_tail];
uart_arr[ch].rx_tail = (uart_arr[ch].rx_tail + 1) % UART_BUFFER_LENGTH;
}
break;
default:
break;
}
return ret;
}
uint16_t UartTxAvailable(uint8_t ch)
{
uint16_t ret = 0;
int length = 0;
switch(ch)
{
case DEF_UART_CHANNEL_0:
length = (uart_arr[ch].tx_header - uart_arr[ch].tx_tail);
if(length < 0)
{
length += UART_BUFFER_LENGTH;
}
ret = length;
break;
default:
break;
}
return ret;
}
uint16_t UartRxAvailable(uint8_t ch)
{
uint16_t ret = 0;
int length = 0;
switch(ch)
{
case DEF_UART_CHANNEL_0:
length = (uart_arr[ch].rx_header - uart_arr[ch].rx_tail);
if(length < 0)
{
length += UART_BUFFER_LENGTH;
}
ret = length;
break;
default:
break;
}
return ret;
}
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
for(int i = 0; i < DEF_UART_CHANNEL_MAX; i++)
{
if(huart == uart_arr[i].phuart_n)
{
if((uart_arr[i].rx_header + 1) % UART_BUFFER_LENGTH != uart_arr[i].rx_tail)
{
uart_arr[i].rx_buffer[uart_arr[i].rx_header] = uart_arr[i].data;
uart_arr[i].rx_header = (uart_arr[i].rx_header + 1) % UART_BUFFER_LENGTH;
}
HAL_UART_Receive_IT(uart_arr[i].phuart_n, &uart_arr[i].data, 1);
break;
}
}
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
{
for(int i = 0; i < DEF_UART_CHANNEL_MAX; i++)
{
if(huart == uart_arr[i].phuart_n)
{
uart_arr[DEF_UART_CHANNEL_0].tx_tail = (uart_arr[DEF_UART_CHANNEL_0].tx_tail + UART_INTERRUPT_LENGTH_MAX) % UART_BUFFER_LENGTH;
if(UartIsEmptyTxBuffer(DEF_UART_CHANNEL_0) != true)
{
UartSendTxBufferInterrupt(DEF_UART_CHANNEL_0, UartTxAvailable(DEF_UART_CHANNEL_0));
}
break;
}
}
}
HAL_StatusTypeDef UartSendTxBufferInterrupt(uint8_t ch, uint16_t length)
{
HAL_StatusTypeDef status = HAL_OK;
switch(ch)
{
case DEF_UART_CHANNEL_0:
if(UartIsEmptyTxBuffer(ch) != true)
{
uint8_t tx_buff_buff = '\0';
if(length > 0)
{
length = UART_INTERRUPT_LENGTH_MAX;
tx_buff_buff = uart_arr[ch].tx_buffer[uart_arr[ch].tx_tail];
status = HAL_UART_Transmit_IT(uart_arr[ch].phuart_n, &tx_buff_buff, length);
}
}
break;
default:
break;
}
return status;
}
HAL_StatusTypeDef UartSendTxBufferPolling(uint8_t ch, uint16_t length)
{
HAL_StatusTypeDef status = HAL_OK;
switch(ch)
{
case DEF_UART_CHANNEL_0:
if(UartIsEmptyTxBuffer(ch) != true)
{
uint8_t tx_buff_buff[8] = {0, };
if(length > 8)
{
length = 8;
}
if(uart_arr[ch].tx_tail + length > UART_BUFFER_LENGTH - 1)
{
int index = 0;
int index_2 = 0;
for(int i = uart_arr[ch].tx_tail; i < UART_BUFFER_LENGTH; i++)
{
tx_buff_buff[index] = uart_arr[ch].tx_buffer[uart_arr[ch].tx_tail];
index++;
}
index_2 = uart_arr[ch].tx_tail + length - (UART_BUFFER_LENGTH - 1) - index;
for(int i = 0; i < index_2; i++)
{
tx_buff_buff[index] = uart_arr[ch].tx_buffer[i];
index++;
}
}
else
{
for(int i = 0; i < length; i++)
{
tx_buff_buff[i] = uart_arr[ch].tx_buffer[uart_arr[ch].tx_tail + i];
}
}
status = HAL_UART_Transmit(uart_arr[ch].phuart_n, tx_buff_buff, length, 10);
if(status == HAL_OK)
{
uart_arr[ch].tx_tail = (uart_arr[ch].tx_tail + length) % UART_BUFFER_LENGTH;
}
}
break;
default:
break;
}
return status;
}
static bool SjkUartInit(uint8_t ch)
{
bool ret = true;
for(int i = 0; i < DEF_UART_CHANNEL_MAX; i++)
{
switch(i)
{
case DEF_UART_CHANNEL_0:
uart_arr[i].phuart_n = &huart1;
HAL_UART_Receive_IT(uart_arr[i].phuart_n, &uart_arr[i].data, 1);
break;
default:
break;
}
}
return ret;
}
static bool AutoUartInit(void)
{
bool ret = true;
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
return ret;
}
|
4f62864acbc57dffbfeb4e5e0fc666771b1339ad
|
8558ad10cde8c6686a24e7fc2561b953b586abd1
|
/MergeSort.c
|
44a6a3486ed849437ab8cc200673cd628cda4960
|
[] |
no_license
|
Proddutghosh/Data-Structure-C-Programming
|
2606a71012253f13701f0fee80bc4995c0539988
|
cf7dacc9e30f5b31c6b645062e468c24213f2609
|
refs/heads/master
| 2021-07-26T00:41:17.736425 | 2020-06-19T17:46:27 | 2020-06-19T17:46:27 | 189,471,754 | 0 | 0 | null | 2019-05-30T19:37:17 | 2019-05-30T19:37:16 | null |
UTF-8
|
C
| false | false | 1,546 |
c
|
MergeSort.c
|
#include<stdlib.h>
#include<stdio.h>
// Merges two subarrays of arr[].
// First subarray is arr[low..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int low, int mid, int high)
{
int i, j, k;
int n1 = mid - low + 1;
int n2 = high - mid;
/* create temp arrays */
int b[n1], c[n2];
/* Copy data to temp arrays low[] and R[] */
for (i = 0; i < n1; i++)
b[i] = arr[low + i];
for (j = 0; j < n2; j++)
c[j] = arr[mid + 1+ j];
i = 0;
j = 0;
k = low;
while (i < n1 && j < n2)
{
if (b[i] <= c[j])
{
arr[k++] = b[i++];
}
else
{
arr[k++] = c[j++];
}
}
while (i < n1)
{
arr[k++] = b[i++];
}
while (j < n2)
{
arr[k++] = c[j++];
}
}
void mergeSort(int arr[], int low, int high)
{
if (low < high)
{
// Same as (low+r)/2, but avoids overflowow for
// lowarge low and h
int mid = low+(high-low)/2;
mergeSort(arr, low, mid);
mergeSort(arr, mid+1, high);
merge(arr, low, mid, high);
}
}
void printArray(int A[], int size)
{
for (int i = 0; i < size; i++)
printf("%d ", A[i]);
printf("\n");
}
int main()
{
int arr[] = {12, 11, 13, 5, 6, 7};
int arr_size = sizeof(arr)/sizeof(arr[0]);
printf("Given array is \n");
printArray(arr, arr_size);
mergeSort(arr, 0, arr_size - 1);
printf("\nSorted array is \n");
printArray(arr, arr_size);
return 0;
}
|
ddcf4f37ce617af9b24a456f9c4a79b7a3b7eea1
|
5d233850c9d16d165d9fc3df2cc412803fcaaf77
|
/libastro/sattypes.h
|
61891ff0369d3321dba92d740e508cde033dd8e3
|
[
"MIT"
] |
permissive
|
audetto/XEphem
|
bf387c724cc5af91a684feb3a81588d401e20fee
|
2bb4ec4918888aee4ba4e74709658f77bbcbf325
|
refs/heads/main
| 2023-06-06T14:00:52.016095 | 2021-06-24T17:24:17 | 2021-06-24T17:24:17 | 380,943,625 | 0 | 0 |
MIT
| 2021-06-28T07:27:17 | 2021-06-28T07:27:16 | null |
UTF-8
|
C
| false | false | 478 |
h
|
sattypes.h
|
#ifndef __SATTYPES_H
#define __SATTYPES_H
/* $Id: sattypes.h,v 1.1 2000/09/25 17:21:25 ecdowney Exp $ */
typedef struct _Vec3 {
double x, y, z;
} Vec3;
typedef struct _LookAngle {
double az;
double el;
double r;
} LookAngle;
typedef struct _Geoloc {
double lt;
double ln;
double h;
} GeoLoc;
#endif /* __SATTYPES_H */
/* For RCS Only -- Do Not Edit
* @(#) $RCSfile: sattypes.h,v $ $Date: 2000/09/25 17:21:25 $ $Revision: 1.1 $ $Name: $
*/
|
3e004248f29031a7636afb568ae879f358b32475
|
c9bc99866cfab223c777cfb741083be3e9439d81
|
/arch/arm/arm-m/include/arch_scatter.h
|
0844f696897b400943e3dd4c4759d7fb194670fd
|
[
"BSD-3-Clause"
] |
permissive
|
ARM-software/SCP-firmware
|
4738ca86ce42d82588ddafc2226a1f353ff2c797
|
f6bcca436768359ffeadd84d65e8ea0c3efc7ef1
|
refs/heads/master
| 2023-09-01T16:13:36.962036 | 2023-08-17T13:00:20 | 2023-08-31T07:43:37 | 134,399,880 | 211 | 165 |
NOASSERTION
| 2023-09-13T14:27:10 | 2018-05-22T10:35:56 |
C
|
UTF-8
|
C
| false | false | 2,513 |
h
|
arch_scatter.h
|
/*
* Arm SCP/MCP Software
* Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
* Description:
* Common linker script configuration options.
*
* There are three supported memory layouts for the ARM-M architectures:
*
* Layout 1 - Single region:
* This layout uses a single read/write/execute memory region for all data.
* This is traditionally used by firmware running from a general-purpose
* RAM region. In this configuration MEM0 represents the RAM region, and
* MEM1 is unused.
*
* Layout 2 - Dual region with relocation:
* This layout uses a read/execute memory region for read-only and
* executable data, and a write memory region for writable data. This is
* traditionally used by firmware running from a ROM region. In this
* configuration MEM0 represents the ROM region and MEM1 represents the RAM
* region.
*
* Layout 3 - Dual region without relocation:
* This layout uses an execute memory region for executable data, and a
* read/write memory region for writable data. This is traditionally used
* by firmware running from a RAM region attached to the instruction bus.
* In this configuration MEM0 represents the RAM region attached to the
* instruction bus and MEM1 represents the RAM region attached to the data
* bus.
*/
#ifndef ARCH_SCATTER_H
#define ARCH_SCATTER_H
#define ARCH_MEM_MODE_SINGLE_REGION 0
#define ARCH_MEM_MODE_DUAL_REGION_RELOCATION 1
#define ARCH_MEM_MODE_DUAL_REGION_NO_RELOCATION 2
#include <fmw_memory.h>
#ifndef FMW_MEM_MODE
# error "FMW_MEM_MODE has not been configured"
#endif
#if (FMW_MEM_MODE != ARCH_MEM_MODE_SINGLE_REGION) && \
(FMW_MEM_MODE != ARCH_MEM_MODE_DUAL_REGION_RELOCATION) && \
(FMW_MEM_MODE != ARCH_MEM_MODE_DUAL_REGION_NO_RELOCATION)
# error "FMW_MEM_MODE has been configured improperly"
#endif
#ifndef FMW_MEM0_BASE
# error "FMW_MEM0_BASE has not been configured"
#endif
#ifndef FMW_MEM0_SIZE
# error "FMW_MEM0_SIZE has not been configured"
#endif
#define ARCH_MEM0_LIMIT (FMW_MEM0_BASE + FMW_MEM0_SIZE)
#if FMW_MEM_MODE != ARCH_MEM_MODE_SINGLE_REGION
# ifndef FMW_MEM1_BASE
# error "FMW_MEM1_BASE has not been configured"
# endif
# ifndef FMW_MEM1_SIZE
# error "FMW_MEM1_SIZE has not been configured"
# endif
# define ARCH_MEM1_LIMIT (FMW_MEM1_BASE + FMW_MEM1_SIZE)
#endif
#endif /* ARCH_SCATTER_H */
|
4823fd5a57e7a098e155423adaef969968a6ac42
|
38576443ef9c6607556961d7309f9fb9b7fafea6
|
/2440test/DMA/main.c
|
e02365460aac8eb998c227b15e19e87aabc10494
|
[] |
no_license
|
kaiqiangjiang/LinuxC
|
09ed3107e80214cf07c22ff112e82769c68a9d86
|
301afa995915a5a6b877ae9e6af7494ec361c4cf
|
refs/heads/master
| 2021-05-30T09:15:59.195264 | 2015-04-27T00:48:16 | 2015-04-27T00:48:16 | null | 0 | 0 | null | null | null | null |
GB18030
|
C
| false | false | 10,903 |
c
|
main.c
|
//======================================================================
// 工程名称: Exa_DMA
// 功能描述: 通过超级终端可以看到DMA测试的结果和DMA传输数据的时长。
// IDE环境: ADS v1.2
// 组成文件: main.c uart.c
// 硬件连接: 无
// 维护记录: 2009-8-14 V1.0 by xgc
//======================================================================
//=============================================================
// 文件名称: main.c
// 功能描述: 定义了主函数
// 维护记录: 2009-8-14 V1.0
//=============================================================
//====================================================
// 包含头文件区
//====================================================
#include "2440addr.h"
#include "2440lib.h"
#include "option.h"
#include "def.h"
#include "uart.h"
#include <string.h>
extern unsigned int PCLK;
//====================================================
// 函数声明区
//====================================================
void __irq Dma0Done(void); //DMA0中断函数
void __irq Dma1Done(void); //DMA1中断函数
void __irq Dma2Done(void); //DMA2中断函数
void __irq Dma3Done(void); //DMA3中断函数
void DMA_M2M(int ch,int srcAddr,int dstAddr,int tc,int dsz,int burst); //内存到内存的DMA数据传输函数
void Test_DMA(void); //DMA传输测试
//====================================================
//变量设置区
//====================================================
/* DMA特殊功能寄存器 */
typedef struct tagDMA
{
volatile U32 DISRC; //0x0 DMA初始源寄存器
volatile U32 DISRCC; //0x4 DMA初始源控制寄存器
volatile U32 DIDST; //0x8 DMA初始目的寄存器
volatile U32 DIDSTC; //0xc DMA初始目的控制寄存器
volatile U32 DCON; //0x10 DMA控制寄存器
volatile U32 DSTAT; //0x14 DMA状态寄存器
volatile U32 DCSRC; //0x18 当前源寄存器
volatile U32 DCDST; //0x1c 当前目的寄存器
volatile U32 DMASKTRIG; //0x20 DMA掩码触发寄存器
}DMA;
static volatile int dmaDone; //DMA传输完成与否标识 0未完成 1完成
void Timer_Start(int divider) //0:16us,1:32us 2:64us 3:128us
{
rWTCON = ((PCLK/1000000-1)<<8)|(divider<<3); //Watch-dog timer control register
rWTDAT = 0xffff; //Watch-dog timer data register
rWTCNT = 0xffff; //Watch-dog count register
// Watch-dog timer enable & interrupt disable
rWTCON = (rWTCON & ~(1<<5) & ~(1<<2)) |(1<<5);
}
//=================================================================
int Timer_Stop(void)
{
rWTCON = ((PCLK/1000000-1)<<8);
return (0xffff - rWTCNT);
}
/********************************************************************
// 语法格式 : void Main(void)
// 功能描述 : DMA操作实验主程序
// 实现功能:
// 实现DMA方式内存到内存的拷贝动作,修改DMA设置
// 并比较其工作效率,实验包括:DMA0-DMA3
// 入口参数 : 无
// 出口参数 : 无
*********************************************************************/
void Main(void)
{
memcpy((U8 *)0x0,(U8 *)0x30000000,0x1000);
SetSysFclk(FCLK_400M); //设置系统时钟 400M
ChangeClockDivider(2,1); //设置分频 1:4:8
CalcBusClk(); //计算总线频
Uart_Select(0);
Uart_Init(0,115200);
Uart_Printf("\n---DMA操作实验主程序---\n");
Test_DMA();
Uart_Printf("\nDMA测试结束\n");
while(1);
}
void Test_DMA(void)
{
//DMA Ch 0 _NONCACHE_STARTADDRESS = 0x30400000
DMA_M2M(0,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x80000,0,0); //byte,single
DMA_M2M(0,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x40000,1,0); //halfword,single
DMA_M2M(0,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,2,0); //word,single
DMA_M2M(0,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,0,1); //byte,burst
DMA_M2M(0,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x10000,1,1); //halfword,burst
DMA_M2M(0,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000, 0x8000,2,1); //word,burst
//DMA Ch 1
DMA_M2M(1,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x80000,0,0); //byte,single
DMA_M2M(1,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x40000,1,0); //halfword,single
DMA_M2M(1,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,2,0); //word,single
DMA_M2M(1,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,0,1); //byte,burst
DMA_M2M(1,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x10000,1,1); //halfword,burst
DMA_M2M(1,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000, 0x8000,2,1); //word,burst
//DMA Ch 2
DMA_M2M(2,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x80000,0,0); //byte,single
DMA_M2M(2,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x40000,1,0); //halfword,single
DMA_M2M(2,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,2,0); //word,single
DMA_M2M(2,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,0,1); //byte,burst
DMA_M2M(2,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x10000,1,1); //halfword,burst
DMA_M2M(2,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000, 0x8000,2,1); //word,burst
//DMA Ch 3
DMA_M2M(3,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x80000,0,0); //byte,single
DMA_M2M(3,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x40000,1,0); //halfword,single
DMA_M2M(3,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,2,0); //word,single
DMA_M2M(3,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x20000,0,1); //byte,burst
DMA_M2M(3,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000,0x10000,1,1); //halfword,burst
DMA_M2M(3,_NONCACHE_STARTADDRESS,_NONCACHE_STARTADDRESS+0x800000, 0x8000,2,1); //word,burst
}
/********************************************************************
// 语法格式:void DMA_M2M(int ch,int srcAddr,int dstAddr,int tc,int dsz,int burst)
// 功能描述: DMA方式内存拷贝
// 入口参数:
// : int ch:DMA通道 0-DMA0, 1-DMA1, 2-DMA2, 3-DMA3
// : int srcAddr:源地址
// : int dstAddr:目的地址
// : int tc:初始传输计数值
// : int dsz:传输数据宽度 0:1字节 1:2字节 2:4字节
// : int burst:自动传输的传输宽度 0-单元传输(一个字节) 1-突发模式传输(四个字节)
// 出口参数: 无
*********************************************************************/
void DMA_M2M(int ch,int srcAddr,int dstAddr,int tc,int dsz,int burst)
{
int i,time;
volatile U32 memSum0=0,memSum1=0;
DMA *pDMA;
int length;
length=tc*(burst ? 4:1)*((dsz==0)+(dsz==1)*2+(dsz==2)*4); //确定一次传输的字节数( 传输单元模式 * 传输数据宽度 )
Uart_Printf("[DMA%d MEM2MEM Test]\n",ch);
switch(ch)
{
case 0:
pISR_DMA0 = (unsigned)Dma0Done;
EnableIrq(BIT_DMA0); //open DMA0 INTERRUPT
pDMA=(void *)0x4b000000;
break;
case 1:
pISR_DMA1 = (unsigned)Dma1Done;
EnableIrq(BIT_DMA1); //open DMA1 INTERRUPT
pDMA=(void *)0x4b000040;
break;
case 2:
pISR_DMA2 = (unsigned)Dma2Done;
EnableIrq(BIT_DMA2); //open DMA2 INTERRUPT
pDMA=(void *)0x4b000080;
break;
case 3:
pISR_DMA3 = (unsigned)Dma3Done;
EnableIrq(BIT_DMA3); //open DMA3 INTERRUPT
pDMA=(void *)0x4b0000c0;
break;
}
Uart_Printf("DMA%d %8xh->%8xh,size=%xh(tc=%xh),dsz=%d,burst=%d\n",ch,
srcAddr,dstAddr,length,tc,dsz,burst);
Uart_Printf("Initialize the src.\n");
for(i=srcAddr;i<(srcAddr+length);i+=4)
{
*((U32 *)i)=i^0x55aa5aa5; //向源地址写入任意数据 写入长度为length
memSum0+=i^0x55aa5aa5; //将写入数据累加,为校验读出数据的准确性
}
Uart_Printf("DMA%d start\n",ch);
dmaDone=0;
pDMA->DISRC=srcAddr; //设置源地址
pDMA->DISRCC=(0<<1)|(0<<0); //设置源控制寄存器 inc,AHB
pDMA->DIDST=dstAddr; //设置目的地址
pDMA->DIDSTC=(0<<1)|(0<<0); //设置目的控制寄存器 inc,AHB
pDMA->DCON=(1<<31)|(1<<30)|(1<<29)|(burst<<28)|(1<<27)|
(0<<23)|(1<<22)|(dsz<<20)|(tc);
//DMA控制寄存器 HS,AHB sync,enable interrupt,whole, SW request mode,relaod off
pDMA->DMASKTRIG=(1<<1)|1; //DMA on, SW_TRIG
Timer_Start(3);//128us resolution
while(dmaDone==0);
time=Timer_Stop();
Uart_Printf("DMA transfer done.\n");
Uart_Printf("time = %u MS\n", time*128/1000);
DisableIrq(BIT_DMA0);
DisableIrq(BIT_DMA1);
DisableIrq(BIT_DMA2);
DisableIrq(BIT_DMA3);
for(i=dstAddr;i<dstAddr+length;i+=4)
{
memSum1+=*((U32 *)i)=i^0x55aa5aa5;
}
Uart_Printf("\n memSum0=%x,memSum1=%x\n",memSum0,memSum1);
if(memSum0==memSum1)
Uart_Printf("DMA test result--------------------------------------O.K.\n");
else
Uart_Printf("DMA test result--------------------------------------ERROR!!!\n");
}
//====================================================
// 语法格式:void __irq Dma0Done(void)
// 功能描述: DMA0中断函数
// 更新DMA0标识
// 入口参数: 无
// 出口参数: 无
//====================================================
void __irq Dma0Done(void)
{
dmaDone=1;
ClearPending(BIT_DMA0);
}
//====================================================
// 语法格式:void __irq Dma1Done(void)
// 功能描述: DMA1中断函数
// 更新DMA标识
// 入口参数: 无
// 出口参数: 无
//====================================================
void __irq Dma1Done(void)
{
dmaDone=1;
ClearPending(BIT_DMA1);
}
//====================================================
// 语法格式:void __irq Dma2Done(void)
// 功能描述: DMA2中断函数
// 更新DMA标识
// 入口参数: 无
// 出口参数: 无
//====================================================
void __irq Dma2Done(void)
{
dmaDone=1;
ClearPending(BIT_DMA2);
}
//====================================================
// 语法格式:void __irq Dma3Done(void)
// 功能描述: DMA3中断函数
// 更新DMA标识
// 入口参数: 无
// 出口参数: 无
//====================================================
void __irq Dma3Done(void)
{
dmaDone=1;
ClearPending(BIT_DMA3);
}
|
b869876f96eb172ede6c1d18b53064b2ba08aab6
|
e762cc749c8a52cf4d5cc8b975b44bd743132a4d
|
/C codes/LInked list/linkedListQue.c
|
adc004866b076eb7d70b0dbae9f0650cd3a4850e
|
[] |
no_license
|
valuecodes/C-programs
|
387a7e0f815ecca178c94a53eca18a8726ccdea9
|
a01d73a77ac6bbfb9ce049af0449c4c32e3e7249
|
refs/heads/master
| 2020-03-25T06:50:00.919592 | 2018-08-09T14:27:26 | 2018-08-09T14:27:26 | 143,526,465 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 3,139 |
c
|
linkedListQue.c
|
#include <stdio.h>
#include <stdlib.h>
struct BstNode
{
int data;
struct BstNode *left;
struct BstNode *right;
}BstNode;
struct Node
{
int data;
struct node *next;
struct node *prev;
}Node;
struct Node *tail;
struct Node* Push(struct Node *head,struct BstNode *data);
struct Node* getNewNode(struct BstNode *data);
// void Print(struct Node *head);
void Pop();
struct BstNode* Insert(struct BstNode *root,int data);
struct BstNode* GetNewBst(int data);
void findLow(struct BstNode *root);
void printLevel(struct BstNode *root);
void Print(struct Node *temp);
int main()
{
struct Node *head;
head=NULL;
tail=NULL;
int i;
struct BstNode *root;
root=NULL;
root=Insert(root,7);
root=Insert(root,3);
root=Insert(root,9);
root=Insert(root,2);
root=Insert(root,8);
root=Insert(root,1);
root=Insert(root,15);
// findLow(root);
// for(i=0;i<50;i=i+4)
// {
// head=Push(head,i);
// if(i>20)
// {
// Pop();
// }
//
// }
printLevel(root);
Print(head);
}
void printLevel(struct BstNode *root)
{
struct Node *head;
head=NULL;
tail=NULL;
// head=Push(head,root);
struct BstNode *l=root->left;
struct BstNode *r=root->right;
head=Push(head,l);
head=Push(head,r);
Print(head);
}
void Print(struct Node *temp)
{
while(temp != NULL)
{
struct BstNode *data;
data=temp->data;
printf("%d ",data->data);
temp=temp->next;
}
}
void findLow(struct BstNode *root)
{
while(root->left != NULL)
{
root=root->left;
}
printf(" low is %d\n",root->data);
}
struct BstNode* Insert(struct BstNode *root,int data)
{
struct BstNode *newNode;
newNode=GetNewBst(data);
if(root==NULL)
{
root=newNode;
return root;
}
else if(root->data <= data)
{
root->right=Insert(root->right,data);
}
else
{
root->left=Insert(root->left,data);
}
return root;
}
struct BstNode* GetNewBst(int data)
{
struct BstNode *newNode;
newNode=(struct BstNode*)malloc(sizeof(struct BstNode));
newNode->data=data;
newNode->left=NULL;
newNode->right=NULL;
return newNode;
}
void Pop()
{
struct Node *temp;
temp=tail;
struct Node *temp2;
temp2=temp->prev;
temp2->next=NULL;
tail=temp2;
free(temp);
}
// void Print(struct Node *head)
// {
// while (head != NULL)
// {
// printf("%d ",head->data);
// head=head->next;
// }
// printf("\n");
// }
struct Node* Push(struct Node *head,struct BstNode *data)
{
struct Node *newNode;
newNode=getNewNode(data);
if(head==NULL)
{
head=newNode;
tail=newNode;
return head;
}
newNode->next=head;
head->prev=newNode;
head=newNode;
return head;
}
struct Node* getNewNode(struct BstNode *data)
{
struct Node* newNode;
newNode=(struct Node*)malloc(sizeof(struct Node));
newNode->data=data;
newNode->next=NULL;
newNode->prev=NULL;
return newNode;
}
|
6164b4b767a2ca79a27451cbe8c29d5c8b1e401e
|
27d5670a7739a866c3ad97a71c0fc9334f6875f2
|
/CPP/include/symbian-r6/snprintf_old.h
|
a69bf130aff265c6af8e791ab4909a183a9c70a8
|
[
"BSD-3-Clause"
] |
permissive
|
ravustaja/Wayfinder-S60-Navigator
|
ef506c418b8c2e6498ece6dcae67e583fb8a4a95
|
14d1b729b2cea52f726874687e78f17492949585
|
refs/heads/master
| 2021-01-16T20:53:37.630909 | 2010-06-28T09:51:10 | 2010-06-28T09:51:10 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 190 |
h
|
snprintf_old.h
|
#include <stdarg.h>
#include <stdlib.h>
int vsnprintf(char *outbuf, size_t maxsize, const char *fmt0, va_list ap);
int snprintf(char *outbuf, size_t maxsize, const char *fmt0, ...);
|
04abbe84b100303ccdcc7728bd2044af335e1aac
|
f443782e48eb0da3a792a1f68ce99e8971b81cc6
|
/libft/ft_vector_init.c
|
6bc2be10a6e68179bb98c3ad4b5d1a2d891f265c
|
[] |
no_license
|
VladCincean/fdf
|
9800c19f10c47c8ff41cd72c493d7540b28d7eff
|
66b8701a2979726d357e2c87761ccbadfb8bea24
|
refs/heads/master
| 2021-01-19T22:01:31.655619 | 2017-03-25T12:16:11 | 2017-03-25T12:16:11 | 83,234,783 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,216 |
c
|
ft_vector_init.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_vector_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vcincean <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/22 14:53:10 by vcincean #+# #+# */
/* Updated: 2017/02/23 11:30:38 by vcincean ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
t_vector *ft_vector_init(int capacity)
{
t_vector *v;
if ((v = (t_vector *)malloc(sizeof(t_vector))) == NULL)
return (NULL);
if ((v->v = (void **)malloc(capacity * sizeof(void *))) == NULL)
{
free(v);
return (NULL);
}
v->size = 0;
v->capacity = capacity;
return (v);
}
|
c918b39fb1741a9073d971cf11fffa993fe2a4c7
|
18330557e13401b59985d02e9f4d851669f63de9
|
/src/kernel/udp.h
|
667ed4a3dacdcc0839476cdaa819f999b8afd670
|
[] |
no_license
|
jimbob843/cheetah
|
293864d2d702379570dd3c4104efb5309a8a6bfd
|
3b515c46cb5b11003c732600a178d359116e0d3d
|
refs/heads/master
| 2021-01-01T04:19:26.059885 | 2016-05-07T13:21:18 | 2016-05-07T13:21:18 | 58,266,462 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 300 |
h
|
udp.h
|
/*
* Cheetah v1.0 Copyright Marlet Limited 2007
*
* File: udp.h
* Description: User Datagram Protocol (Header)
* Author: James Smith
* Created: 10-May-2007
* Last Modified: 10-May-2007
*
*/
#include "kernel.h"
void udp_PacketHandler( BYTE *buffer, WORD length, DWORD sourceIP );
|
bab890c1c6e7724906b3cf434b1fa3b2272d3ac0
|
ee7ebbb65e39d6e222cf9300e7c3bc5acecd38c9
|
/driver/utils.c
|
8f043024a7e2356312d08231cbb17ee0791227e4
|
[
"MIT"
] |
permissive
|
fengjixuchui/asynccom-windows
|
97616df4978c14c1d2f51bd2a8a7c925d93a2524
|
33f0802dc5a64b1db83a3690959845e5a1c90ab0
|
refs/heads/master
| 2022-04-05T06:39:20.904265 | 2020-01-21T20:29:46 | 2020-01-21T20:29:46 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 38,822 |
c
|
utils.c
|
/*
Copyright 2019 Commtech, Inc.
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 <utils.h>
#include <port.h>
#include <Ntstrsafe.h>
PCHAR get_ioctl_name(ULONG ioctl_code)
{
switch (ioctl_code)
{
case IOCTL_SERIAL_SET_BAUD_RATE: return "IOCTL_SERIAL_SET_BAUD_RATE";
case IOCTL_SERIAL_GET_BAUD_RATE: return "IOCTL_SERIAL_GET_BAUD_RATE";
case IOCTL_SERIAL_GET_MODEM_CONTROL: return "IOCTL_SERIAL_GET_MODEM_CONTROL";
case IOCTL_SERIAL_SET_MODEM_CONTROL: return "IOCTL_SERIAL_SET_MODEM_CONTROL";
case IOCTL_SERIAL_SET_FIFO_CONTROL: return "IOCTL_SERIAL_SET_FIFO_CONTROL";
case IOCTL_SERIAL_SET_LINE_CONTROL: return "IOCTL_SERIAL_SET_LINE_CONTROL";
case IOCTL_SERIAL_GET_LINE_CONTROL: return "IOCTL_SERIAL_GET_LINE_CONTROL";
case IOCTL_SERIAL_SET_TIMEOUTS: return "IOCTL_SERIAL_SET_TIMEOUTS";
case IOCTL_SERIAL_GET_TIMEOUTS: return "IOCTL_SERIAL_GET_TIMEOUTS";
case IOCTL_SERIAL_SET_CHARS: return "IOCTL_SERIAL_SET_CHARS";
case IOCTL_SERIAL_GET_CHARS: return "IOCTL_SERIAL_GET_CHARS";
case IOCTL_SERIAL_SET_DTR: return "IOCTL_SERIAL_SET_DTR";
case IOCTL_SERIAL_CLR_DTR: return "IOCTL_SERIAL_SET_DTR";
case IOCTL_SERIAL_RESET_DEVICE: return "IOCTL_SERIAL_RESET_DEVICE";
case IOCTL_SERIAL_SET_RTS: return "IOCTL_SERIAL_SET_RTS";
case IOCTL_SERIAL_CLR_RTS: return "IOCTL_SERIAL_CLR_RTS";
case IOCTL_SERIAL_SET_XOFF: return "IOCTL_SERIAL_SET_XOFF";
case IOCTL_SERIAL_SET_XON: return "IOCTL_SERIAL_SET_XON";
case IOCTL_SERIAL_SET_BREAK_ON: return "IOCTL_SERIAL_SET_BREAK_ON";
case IOCTL_SERIAL_SET_BREAK_OFF: return "IOCTL_SERIAL_SET_BREAK_OFF";
case IOCTL_SERIAL_SET_QUEUE_SIZE: return "IOCTL_SERIAL_SET_QUEUE_SIZE";
case IOCTL_SERIAL_GET_WAIT_MASK: return "IOCTL_SERIAL_GET_WAIT_MASK";
case IOCTL_SERIAL_SET_WAIT_MASK: return "IOCTL_SERIAL_SET_WAIT_MASK";
case IOCTL_SERIAL_WAIT_ON_MASK: return "IOCTL_SERIAL_WAIT_ON_MASK";
case IOCTL_SERIAL_IMMEDIATE_CHAR: return "IOCTL_SERIAL_IMMEDIATE_CHAR";
case IOCTL_SERIAL_PURGE: return "IOCTL_SERIAL_PURGE";
case IOCTL_SERIAL_GET_HANDFLOW: return "IOCTL_SERIAL_GET_HANDFLOW";
case IOCTL_SERIAL_SET_HANDFLOW: return "IOCTL_SERIAL_SET_HANDFLOW";
case IOCTL_SERIAL_GET_MODEMSTATUS: return "IOCTL_SERIAL_GET_MODEMSTATUS";
case IOCTL_SERIAL_GET_DTRRTS: return "IOCTL_SERIAL_GET_DTRRTS";
case IOCTL_SERIAL_GET_COMMSTATUS: return "IOCTL_SERIAL_GET_COMMSTATUS";
case IOCTL_SERIAL_GET_PROPERTIES: return "IOCTL_SERIAL_GET_PROPERTIES";
case IOCTL_SERIAL_XOFF_COUNTER: return "IOCTL_SERIAL_XOFF_COUNTER";
case IOCTL_SERIAL_LSRMST_INSERT: return "IOCTL_SERIAL_LSRMST_INSERT";
case IOCTL_SERIAL_CONFIG_SIZE: return "IOCTL_SERIAL_CONFIG_SIZE";
case IOCTL_SERIAL_GET_STATS: return "IOCTL_SERIAL_GET_STATS";
case IOCTL_SERIAL_CLEAR_STATS: return "IOCTL_SERIAL_CLEAR_STATS";
case IOCTL_ASYNCCOM_SET_CLOCK_RATE: return "IOCTL_ASYNCCOM_SET_CLOCK_RATE";
case IOCTL_ASYNCCOM_SET_SAMPLE_RATE: return "IOCTL_ASYNCCOM_SET_SAMPLE_RATE";
case IOCTL_ASYNCCOM_GET_SAMPLE_RATE: return "IOCTL_ASYNCCOM_GET_SAMPLE_RATE";
case IOCTL_ASYNCCOM_REPROGRAM: return "IOCTL_ASYNCCOM_REPROGRAM";
case IOCTL_ASYNCCOM_SET_DIVISOR: return "IOCTL_ASYNCCOM_SET_DIVISOR";
case IOCTL_ASYNCCOM_SET_TX_TRIGGER: return "IOCTL_ASYNCCOM_SET_TX_TRIGGER";
case IOCTL_ASYNCCOM_GET_TX_TRIGGER: return "IOCTL_ASYNCCOM_GET_TX_TRIGGER";
case IOCTL_ASYNCCOM_SET_RX_TRIGGER: return "IOCTL_ASYNCCOM_SET_RX_TRIGGER";
case IOCTL_ASYNCCOM_GET_RX_TRIGGER: return "IOCTL_ASYNCCOM_GET_RX_TRIGGER";
case IOCTL_ASYNCCOM_SET_EXTERNAL_TRANSMIT: return "IOCTL_ASYNCCOM_SET_EXTERNAL_TRANSMIT";
case IOCTL_ASYNCCOM_GET_EXTERNAL_TRANSMIT: return "IOCTL_ASYNCCOM_GET_EXTERNAL_TRANSMIT";
case IOCTL_ASYNCCOM_SET_FRAME_LENGTH: return "IOCTL_ASYNCCOM_SET_FRAME_LENGTH";
case IOCTL_ASYNCCOM_GET_FRAME_LENGTH: return "IOCTL_ASYNCCOM_GET_FRAME_LENGTH";
case IOCTL_ASYNCCOM_ENABLE_ECHO_CANCEL: return "IOCTL_ASYNCCOM_ENABLE_ECHO_CANCEL";
case IOCTL_ASYNCCOM_DISABLE_ECHO_CANCEL: return "IOCTL_ASYNCCOM_DISABLE_ECHO_CANCEL";
case IOCTL_ASYNCCOM_GET_ECHO_CANCEL: return "IOCTL_ASYNCCOM_GET_ECHO_CANCEL";
case IOCTL_ASYNCCOM_ENABLE_RS485: return "IOCTL_ASYNCCOM_ENABLE_RS485";
case IOCTL_ASYNCCOM_DISABLE_RS485: return "IOCTL_ASYNCCOM_DISABLE_RS485";
case IOCTL_ASYNCCOM_GET_RS485: return "IOCTL_ASYNCCOM_GET_RS485";
case IOCTL_ASYNCCOM_ENABLE_9BIT: return "IOCTL_ASYNCCOM_ENABLE_9BIT";
case IOCTL_ASYNCCOM_DISABLE_9BIT: return "IOCTL_ASYNCCOM_DISABLE_9BIT";
case IOCTL_ASYNCCOM_GET_9BIT: return "IOCTL_ASYNCCOM_GET_9BIT";
case IOCTL_ASYNCCOM_ENABLE_ISOCHRONOUS: return "IOCTL_ASYNCCOM_ENABLE_ISOCHRONOUS";
case IOCTL_ASYNCCOM_DISABLE_ISOCHRONOUS: return "IOCTL_ASYNCCOM_DISABLE_ISOCHRONOUS";
case IOCTL_ASYNCCOM_GET_ISOCHRONOUS: return "IOCTL_ASYNCCOM_GET_ISOCHRONOUS";
}
return "Unknown IOCTL";
}
UINT32 chars_to_u32(const unsigned char *data)
{
return *((UINT32*)data);
}
BOOLEAN is_queue_empty(IN WDFQUEUE Queue)
{
WDF_IO_QUEUE_STATE queueStatus;
queueStatus = WdfIoQueueGetState(Queue, NULL, NULL);
return (WDF_IO_QUEUE_IDLE(queueStatus)) ? TRUE : FALSE;
}
int GetICS30703Data(unsigned long desired, unsigned long ppm, struct ResultStruct *theOne, struct IcpRsStruct *theOther, unsigned char *progdata)
{
// double inputfreq=18432000.0;
double inputfreq = 24000000.0;
ULONG od = 0; //Output Divider
unsigned r = 0;
unsigned v = 0;
unsigned V_Divstart = 0;
double freq = 0;
// ULONG bestFreq = 0;
// ULONG check = 0;
unsigned maxR = 0;
unsigned minR = 0;
unsigned max_V = 2055;
unsigned min_V = 12;
double allowable_error;
double freq_err;
struct ResultStruct Results;
ULONG i, j;
struct IcpRsStruct IRStruct;
unsigned count;
ULONG Rs;
// double optimal_ratio = 15.0;
// double optimal_df = 0.7;
// double best_ratio = 0;
// double best_df = 0;
double rule1, rule2;
int tempint;
int InputDivider = 0;
int VCODivider = 0;
ULONG ChargePumpCurrent = 0;
ULONG LoopFilterResistor = 0;
ULONG OutputDividerOut1 = 0;
// ULONG OutputDividerOut2 = 0;
// ULONG OutputDividerOut3 = 0;
ULONG temp = 0;
unsigned long requestedppm;
requestedppm = ppm;
if (inputfreq == 18432000.0)
{
maxR = 921;
minR = 1;
}
else if (inputfreq == 24000000.0)
{
maxR = 1200;
minR = 1;
}
ppm = 0;
increaseppm:
// DbgPrint("ICS30703: ppm = %d\n",ppm);
allowable_error = ppm * desired / 1e6; // * 1e6
for (r = minR; r <= maxR; r++)
{
rule2 = inputfreq / (double)r;
if ((rule2 < 20000.0) || (rule2 > 100000000.0))
{
// DbgPrint("Rule2(r=%d): 20,000<%f<100000000\n",r,rule2);
continue; //next r
}
od = 8232;
while (od > 1)
{
//set starting VCO setting with output freq just below target
V_Divstart = (int)(((desired - (allowable_error)) * r * od) / (inputfreq));
//check if starting VCO setting too low
if (V_Divstart < min_V)
V_Divstart = min_V;
//check if starting VCO setting too high
else if (V_Divstart > max_V)
V_Divstart = max_V;
/** Loop thru VCO divide settings**/
//Loop through all VCO divider ratios
for (v = V_Divstart; v <= max_V; v++) //Check all Vco divider settings
{
rule1 = (inputfreq * ((double)v / (double)r));
if (od == 2)
{
if ((rule1 < 90000000.0) || (rule1 > 540000000.0))
{
continue; //next VCO_Div
}
}
else if (od == 3)
{
if ((rule1 < 90000000.0) || (rule1 > 720000000.0))
{
continue; //next VCO_Div
}
}
else if ((od >= 38) && (od <= 1029))
{
if ((rule1 < 90000000.0) || (rule1 > 570000000.0))
{
continue; //next VCO_Div
}
}
else
{
if ((rule1 < 90000000.0) || (rule1 > 730000000.0))
{
// printf("Rule1: 90MHz<%f<730MHz\n",rule1);
continue; //next VCO_Div
}
}
freq = (inputfreq * ((double)v / ((double)r * (double)od)));
freq_err = fabs(freq - desired); //Hz
if ((freq_err) > allowable_error)
{
continue; //next VCO_Div
}
else if ((freq_err) <= allowable_error)
{
count = 0;
for (i = 0; i < 4; i++)
{
switch (i)
{
case 0:
Rs = 64000;
break;
case 1:
Rs = 52000;
break;
case 2:
Rs = 16000;
break;
case 3:
Rs = 4000;
break;
default:
return 1;
}
for (j = 0; j < 20; j++)
{
IRStruct.Rs = Rs;
switch (j)
{
case 0:
IRStruct.icp = 1.25e-6;
IRStruct.icpnum = 125;
break;
case 1:
IRStruct.icp = 2.5e-6;
IRStruct.icpnum = 250;
break;
case 2:
IRStruct.icp = 3.75e-6;
IRStruct.icpnum = 375;
break;
case 3:
IRStruct.icp = 5.0e-6;
IRStruct.icpnum = 500;
break;
case 4:
IRStruct.icp = 6.25e-6;
IRStruct.icpnum = 625;
break;
case 5:
IRStruct.icp = 7.5e-6;
IRStruct.icpnum = 750;
break;
case 6:
IRStruct.icp = 8.75e-6;
IRStruct.icpnum = 875;
break;
case 7:
IRStruct.icp = 10.0e-6;
IRStruct.icpnum = 1000;
break;
case 8:
IRStruct.icp = 11.25e-6;
IRStruct.icpnum = 1125;
break;
case 9:
IRStruct.icp = 12.5e-6;
IRStruct.icpnum = 1250;
break;
case 10:
IRStruct.icp = 15.0e-6;
IRStruct.icpnum = 1500;
break;
case 11:
IRStruct.icp = 17.5e-6;
IRStruct.icpnum = 1750;
break;
case 12:
IRStruct.icp = 18.75e-6;
IRStruct.icpnum = 1875;
break;
case 13:
IRStruct.icp = 20.0e-6;
IRStruct.icpnum = 2000;
break;
case 14:
IRStruct.icp = 22.5e-6;
IRStruct.icpnum = 2250;
break;
case 15:
IRStruct.icp = 25.0e-6;
IRStruct.icpnum = 2500;
break;
case 16:
IRStruct.icp = 26.25e-6;
IRStruct.icpnum = 2625;
break;
case 17:
IRStruct.icp = 30.0e-6;
IRStruct.icpnum = 3000;
break;
case 18:
IRStruct.icp = 35.0e-6;
IRStruct.icpnum = 3500;
break;
default:
DbgPrint("ICS30703: switch(j:icp) - You shouldn't get here! %d\n", j);
case 19:
IRStruct.icp = 40.0e-6;
IRStruct.icpnum = 4000;
break;
}//end switch(j)
// printf("Rs=%5d ",IRStruct.Rs);
// printf("Icp=%2.2f ",IRStruct.icp*10e5);
IRStruct.pdf = (inputfreq / (double)r);
// printf("pdf=%12.2f ",IRStruct.pdf);
IRStruct.nbw = (((double)IRStruct.Rs * IRStruct.icp * 310.0e6) / (2.0 * 3.14159 * (double)v));
// printf("nbw=%15.3f ",IRStruct.nbw);
IRStruct.ratio = (IRStruct.pdf / IRStruct.nbw);
tempint = (int)(IRStruct.ratio*10.0);
if ((IRStruct.ratio*10.0) - tempint >= 0.0) tempint++;
IRStruct.ratio = (double)tempint / 10.0;
// IRStruct.ratio = ceil(IRStruct.ratio*10.0); //these two statements make the
// IRStruct.ratio = IRStruct.ratio/10.0; //ratio a little nicer to compare
// printf("ratio=%2.4f ",IRStruct.ratio);
IRStruct.df = (((double)IRStruct.Rs / 2) * (sqrt(((IRStruct.icp * 0.093) / (double)v))));
// printf("ndf=%12.3f\n",IRStruct.df);
count++;
if ((IRStruct.ratio > 30) || (IRStruct.ratio < 7) || (IRStruct.df > 2.0) || (IRStruct.df < 0.2))
{
continue;
}
else
{
Results.target = desired;
Results.freq = freq;
Results.errorPPM = freq_err / desired * 1.0e6;
Results.VCO_Div = v;
Results.refDiv = r;
Results.outDiv = od;
Results.failed = FALSE;
goto finished;
}
}//end for(j=0;j<20;j++)
}//end for(i=0;i<4;i++)
}
}//end of for( v = V_Divstart; v < max_V; v++ )
if (od <= 1030)
od--;
else if (od <= 2060)
od = od - 2;
else if (od <= 4120)
od = od - 4;
else od = od - 8;
}//end of while(od <= 8232)
}//end of for( r = maxR, *saved_result_num = 0; r >= minR; r-- )
ppm++;
if (ppm > requestedppm)
{
return 2;
}
else
{
// DbgPrint("ICS30703: increasing ppm to %d\n",ppm);
goto increaseppm;
}
finished:
memcpy(theOne, &Results, sizeof(struct ResultStruct));
memcpy(theOther, &IRStruct, sizeof(struct IcpRsStruct));
/*
DbgPrint("ICS30703: Best result is \n");
DbgPrint("\tRD = %4i,",Results.refDiv);
DbgPrint(" VD = %4i,",Results.VCO_Div);
DbgPrint(" OD = %4i,",Results.outDiv);
DbgPrint(" freq_Hz = %ld,\n",(ULONG)Results.freq);
DbgPrint("\tRs = %5d, ",IRStruct.Rs);
DbgPrint("Icp = %d, ",(ULONG)(IRStruct.icp*1e6));
// DbgPrint("pdf = %d, ",(ULONG)IRStruct.pdf);
// DbgPrint("nbw = %d, ",(ULONG)IRStruct.nbw);
DbgPrint("ratio = %d, ",(ULONG)IRStruct.ratio);
DbgPrint("df = %d\n",(ULONG)IRStruct.df*1000);
*/
// DbgPrint("ICS307-03 freq_Hz = %ld,\n",(ULONG)Results.freq);
/*
first, choose the best dividers (V, R, and OD) with
1st key best accuracy
2nd key lowest reference divide
3rd key highest VCO frequency (OD)
then choose the best loop filter with
1st key best PDF/NBW ratio (between 7 and 30, 15 is optimal)
2nd key best damping factor (between 0.2 and 2, 0.7 is optimal)
*/
/* this is 1MHz
progdata[19]=0xff;
progdata[18]=0xff;
progdata[17]=0xff;
progdata[16]=0xf0;
progdata[15]=0x00;
progdata[14]=0x01;
progdata[13]=0x43;
progdata[12]=0x1a;
progdata[11]=0x9c;
progdata[10]=0x00;
progdata[9]=0x00;
progdata[8]=0x00;
progdata[7]=0x00;
progdata[6]=0x00;
progdata[5]=0x00;
progdata[4]=0x00;
progdata[3]=0x00;
progdata[2]=0x0c;
progdata[1]=0xdf;
progdata[0]=0xee;
goto doitnow;
*/
/* 10 MHz
progdata[19]=0xff;
progdata[18]=0xff;
progdata[17]=0xff;
progdata[16]=0x00;
progdata[15]=0x80;
progdata[14]=0x01;
progdata[13]=0x00;
progdata[12]=0x66;
progdata[11]=0x38;
progdata[10]=0x00;
progdata[9]=0x00;
progdata[8]=0x00;
progdata[7]=0x00;
progdata[6]=0x00;
progdata[5]=0x00;
progdata[4]=0x00;
progdata[3]=0x00;
progdata[2]=0x07;
progdata[1]=0x20;
progdata[0]=0x12;
goto doitnow;
*/
progdata[19] = 0xff;
progdata[18] = 0xff;
progdata[17] = 0xff;
progdata[16] = 0x00;
progdata[15] = 0x00;
progdata[14] = 0x00;
progdata[13] = 0x00;
progdata[12] = 0x00;
progdata[11] = 0x00;
progdata[10] = 0x00;
progdata[9] = 0x00;
progdata[8] = 0x00;
progdata[7] = 0x00;
progdata[6] = 0x00;
progdata[5] = 0x00;
progdata[4] = 0x00;
progdata[3] = 0x00;
progdata[2] = 0x00;
progdata[1] = 0x00;
progdata[0] = 0x00;
// progdata[16]|=0x02; //enable CLK3
// progdata[15]&=0xef; //CLK3 source select: 1=CLK1, 0=CLK1 before OD
// progdata[15]|=0x08; //CLK2 source select: 1=CLK1, 0=CLK1 before OD
// progdata[15]|=0x40; //reference source is: 1=crystal, 0=clock
progdata[14] |= 0x01; //1=Power up, 0=power down feedback counter, charge pump and VCO
// progdata[13]|=0x80; //enable CLK2
progdata[13] |= 0x40; //enable CLK1
InputDivider = theOne->refDiv;
VCODivider = theOne->VCO_Div;
ChargePumpCurrent = theOther->icpnum;
LoopFilterResistor = theOther->Rs;
OutputDividerOut1 = theOne->outDiv;
//InputDivider=2;
//VCODivider=60;
//OutputDividerOut1 = 45;
//LoopFilterResistor=16000;
//ChargePumpCurrent=3500;
/* Table 1: Input Divider */
if ((InputDivider == 1) || (InputDivider == 2))
{
switch (InputDivider)
{
case 1:
progdata[0] &= 0xFC;
progdata[1] &= 0xF0;
break;
case 2:
progdata[0] &= 0xFC;
progdata[0] |= 0x01;
progdata[1] &= 0xF0;
break;
}
// printf("1 0x%2.2X,0x%2.2X\n",progdata[1],progdata[0]);
}
else if ((InputDivider >= 3) && (InputDivider <= 17))
{
temp = ~(InputDivider - 2);
temp = (temp << 2);
progdata[0] = (unsigned char)temp & 0xff;
progdata[0] &= 0x3e; //set bit 0 to a 0
progdata[0] |= 0x02; //set bit 1 to a 1
// printf("2 0x%2.2X,0x%2.2X\n",progdata[1],progdata[0]);
}
else if ((InputDivider >= 18) && (InputDivider <= 2055))
{
temp = InputDivider - 8;
temp = (temp << 2);
progdata[0] = (unsigned char)temp & 0xff;
progdata[1] = (unsigned char)((temp >> 8) & 0xff);
progdata[0] |= 0x03; //set bit 0 and 1 to a 1
// printf("3 0x%2.2X,0x%2.2X\n",progdata[1],progdata[0]);
}
else
return 3;
/* Table 2 VCO Divider */
if ((VCODivider >= 12) && (VCODivider <= 2055))
{
temp = VCODivider - 8;
temp = (temp << 5);
progdata[1] |= temp & 0xff;
progdata[2] |= ((temp >> 8) & 0xff);
// printf("4 0x%2.2X,0x%2.2X\n",progdata[2],progdata[1]);
}
else return 4;
/* Table 4 Loop Filter Resistor */
switch (LoopFilterResistor)
{
case 64000:
progdata[11] &= 0xf9; //bit 89 and 90 = 0
break;
case 52000:
progdata[11] &= 0xf9; //bit 89 = 0
progdata[11] |= 0x04; //bit 90 = 1
break;
case 16000:
progdata[11] &= 0xf9; //bit 90 = 0
progdata[11] |= 0x02; //bit 89 = 1
break;
case 4000:
progdata[11] |= 0x06; //bit 89 and 90 = 1
break;
default:
return 5;
}
// printf("5 0x%2.2X\n",progdata[11]);
/* Table 3 Charge Pump Current */
switch (ChargePumpCurrent)
{
case 125:
progdata[11] |= 0x38;
progdata[15] &= 0x7f;
progdata[16] &= 0xfe;
// printf("125\n");
break;
case 250:
progdata[11] |= 0x38;
progdata[15] |= 0x80;
progdata[16] &= 0xfe;
break;
case 375:
progdata[11] |= 0x38;
progdata[15] &= 0x7f;
progdata[16] |= 0x01;
break;
case 500:
progdata[11] |= 0x38;
progdata[15] |= 0x80;
progdata[16] |= 0x01;
break;
case 625:
progdata[11] |= 0x18;
progdata[11] &= 0xdf;
progdata[15] &= 0x7f;
progdata[16] &= 0xfe;
break;
case 750:
progdata[11] |= 0x10;
progdata[11] &= 0xd7;
progdata[15] &= 0x7f;
progdata[16] &= 0xfe;
break;
case 875:
progdata[11] |= 0x08;
progdata[11] &= 0xcf;
progdata[15] &= 0x7f;
progdata[16] &= 0xfe;
break;
case 1000:
progdata[11] &= 0xc7;
progdata[15] &= 0x7f;
progdata[16] &= 0xfe;
break;
case 1125:
progdata[11] |= 0x28;
progdata[11] &= 0xef;
progdata[15] &= 0x7f;
progdata[16] |= 0x01;
break;
case 1250:
progdata[11] |= 0x18;
progdata[11] &= 0xdf;
progdata[15] |= 0x80;
progdata[16] &= 0xfe;
break;
case 1500:
progdata[11] |= 0x28;
progdata[11] &= 0xef;
progdata[15] |= 0x80;
progdata[16] |= 0x01;
break;
case 1750:
progdata[11] |= 0x08;
progdata[11] &= 0xcf;
progdata[15] |= 0x80;
progdata[16] &= 0xfe;
break;
case 1875:
progdata[11] |= 0x18;
progdata[11] &= 0xdf;
progdata[15] &= 0x7f;
progdata[16] |= 0x01;
break;
case 2000:
progdata[11] &= 0xc7;
progdata[15] |= 0x80;
progdata[16] &= 0xfe;
break;
case 2250:
progdata[11] |= 0x10;
progdata[15] &= 0x7f;
progdata[16] |= 0x01;
break;
case 2500:
progdata[11] |= 0x18;
progdata[11] &= 0xdf;
progdata[15] |= 0x80;
progdata[16] |= 0x01;
break;
case 2625:
progdata[11] |= 0x08;
progdata[11] &= 0xcf;
progdata[15] &= 0x7f;
progdata[16] |= 0x01;
break;
case 3000:
progdata[11] &= 0xc7;
progdata[15] &= 0x7f;
progdata[16] |= 0x01;
break;
case 3500:
progdata[11] |= 0x08;
progdata[11] &= 0xcf;
progdata[15] |= 0x80;
progdata[16] |= 0x01;
break;
case 4000:
progdata[11] &= 0xc7;
progdata[15] |= 0x80;
progdata[16] |= 0x01;
break;
default:
return 6;
}//end switch(j)
// printf("6 0x%2.2X, 0x%2.2X, 0x%2.2X\n",progdata[16],progdata[15],progdata[11]);
/* Table 5 Output Divider for Output 1 */
//OutputDividerOut1=38;
if ((OutputDividerOut1 >= 2) && (OutputDividerOut1 <= 8232))
{
switch (OutputDividerOut1)
{
case 2:
progdata[11] &= 0x7f;
progdata[12] &= 0x00;
progdata[13] &= 0xc0;
break;
case 3:
progdata[11] |= 0x80;
progdata[12] &= 0x00;
progdata[13] &= 0xc0;
break;
case 4:
progdata[11] &= 0x7f;
progdata[12] |= 0x04;
progdata[13] &= 0xc0;
break;
case 5:
progdata[11] &= 0x7f;
progdata[12] |= 0x01;
progdata[13] &= 0xc0;
break;
case 6:
progdata[11] |= 0x80;
progdata[12] |= 0x04;
progdata[13] &= 0xc0;
break;
case 7:
progdata[11] |= 0x80;
progdata[12] |= 0x01;
progdata[13] &= 0xc0;
break;
case 11:
progdata[11] |= 0x80;
progdata[12] |= 0x09;
progdata[13] &= 0xc0;
break;
case 9:
progdata[11] |= 0x80;
progdata[12] |= 0x05;
progdata[13] &= 0xc0;
break;
case 13:
progdata[11] |= 0x80;
progdata[12] |= 0x0d;
progdata[13] &= 0xc0;
break;
case 8: case 10: case 12: case 14: case 15: case 16: case 17:case 18: case 19:
case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28:
case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37:
temp = ~(OutputDividerOut1 - 6);
temp = (temp << 2);
progdata[12] = (unsigned char)temp & 0x7f;
progdata[11] &= 0x7f;
progdata[12] &= 0xfe;
progdata[12] |= 0x02;
progdata[13] &= 0xc0;
break;
default:
for (i = 0; i < 512; i++)
{
if (OutputDividerOut1 == ((((i + 3) * 2) + 0)*(1)))
{
// printf("1 x=%d, y=0, z=0\n",i);
// DbgPrint("outputdivider1\n");
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] &= 0xe7;
progdata[12] |= 0x04;
break;
}
else if (OutputDividerOut1 == ((((i + 3) * 2) + 0)*(2)))
{
// printf("2 x=%d, y=0, z=1\n",i);
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] &= 0xef;
progdata[12] |= 0x0c;
break;
}
else if (OutputDividerOut1 == ((((i + 3) * 2) + 0)*(4)))
{
// printf("3 x=%d, y=0, z=2\n",i);
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] &= 0xf7;
progdata[12] |= 0x14;
break;
}
else if (OutputDividerOut1 == ((((i + 3) * 2) + 0)*(8)))
{
// printf("4 x=%d, y=0, z=3\n",i);
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] |= 0x1c;
break;
}
else if (OutputDividerOut1 == ((((i + 3) * 2) + 1)*(1)))
{
// printf("5 x=%d, y=1, z=0\n",i);
// DbgPrint("outputdivider5\n");
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] &= 0xe3;
break;
}
else if (OutputDividerOut1 == ((((i + 3) * 2) + 1)*(2)))
{
// printf("6 x=%d, y=1, z=1\n",i);
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] &= 0xeb; //power of 1
progdata[12] |= 0x08;
break;
}
else if (OutputDividerOut1 == ((((i + 3) * 2) + 1)*(4)))
{
// printf("7 x=%d, y=1, z=2\n",i);
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] &= 0xf7;
progdata[12] |= 0x10;
break;
}
else if (OutputDividerOut1 == ((((i + 3) * 2) + 1)*(8)))
{
// printf("8 x=%d, y=1, z=3\n",i);
temp = (i << 5);
progdata[12] |= (temp & 0xff);
progdata[13] |= (temp >> 8) & 0xff;
progdata[12] &= 0xfb;
progdata[12] |= 0x18;
break;
}
}
progdata[11] |= 0x80; //1
progdata[12] &= 0xfe; //0
progdata[12] |= 0x02; //1
}
// printf("0x%2.2x, 0x%2.2x, 0x%2.2x\n\n",progdata[13]&0x3f, progdata[12], progdata[11]&0x80);
}
else return 7;
//doitnow:
/* progdata[15]|=0x03; //this will set
progdata[14]|=0xc0; //the OD of clock 3
progdata[11]&=0xbf; //to 2
*/
return 0;
}
#define PARAMATER_NAME_LEN 80
NTSTATUS serial_get_defaults(PSERIAL_FIRMWARE_DATA defaults_data, WDFDRIVER Driver)
{
NTSTATUS status = STATUS_SUCCESS; // return value
WDFKEY hKey;
DECLARE_UNICODE_STRING_SIZE(valueName, PARAMATER_NAME_LEN);
status = WdfDriverOpenParametersRegistryKey(Driver, STANDARD_RIGHTS_ALL, WDF_NO_OBJECT_ATTRIBUTES, &hKey);
if (!NT_SUCCESS(status)) {
return status;
}
status = RtlUnicodeStringPrintf(&valueName, L"RS485");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->RS485Default);
if (!NT_SUCCESS(status)) {
defaults_data->RS485Default = SERIAL_RS485_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->RS485Default);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"SampleRate");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->SampleRateDefault);
if (!NT_SUCCESS(status)) {
defaults_data->SampleRateDefault = SERIAL_SAMPLE_RATE_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->SampleRateDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"RxTrigger");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->RxTriggerDefault);
if (!NT_SUCCESS(status)) {
defaults_data->RxTriggerDefault = SERIAL_RX_TRIGGER_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->RxTriggerDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"TxTrigger");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->TxTriggerDefault);
if (!NT_SUCCESS(status)) {
defaults_data->TxTriggerDefault = SERIAL_TX_TRIGGER_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->TxTriggerDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"EchoCancel");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->EchoCancelDefault);
if (!NT_SUCCESS(status)) {
defaults_data->EchoCancelDefault = SERIAL_ECHO_CANCEL_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->EchoCancelDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"Isochronous");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->IsochronousDefault);
if (!NT_SUCCESS(status)) {
defaults_data->IsochronousDefault = (ULONG)SERIAL_ISOCHRONOUS_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->IsochronousDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"FrameLength");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->FrameLengthDefault);
if (!NT_SUCCESS(status)) {
defaults_data->FrameLengthDefault = SERIAL_FRAME_LENGTH_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->FrameLengthDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"9Bit");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->NineBitDefault);
if (!NT_SUCCESS(status)) {
defaults_data->NineBitDefault = SERIAL_9BIT_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->NineBitDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
status = RtlUnicodeStringPrintf(&valueName, L"FixedBaudRate");
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
status = WdfRegistryQueryULong(hKey, &valueName, &defaults_data->FixedBaudRateDefault);
if (!NT_SUCCESS(status)) {
defaults_data->FixedBaudRateDefault = (ULONG)SERIAL_FIXED_BAUD_RATE_DEFAULT;
status = WdfRegistryAssignULong(hKey, &valueName, defaults_data->FixedBaudRateDefault);
if (!NT_SUCCESS(status)) {
WdfRegistryClose(hKey);
return (status);
}
}
WdfRegistryClose(hKey);
return (status);
}
|
63cc78ab32de402e81264b97abf1a8a868211c58
|
7f72135ac04da009939f37b2974449f36b59f83a
|
/wireless/routes/maodv/engine/route/route_task.c
|
672e2c94c9876736a961629383390d32f5be08ba
|
[] |
no_license
|
jacklee032016/wireless
|
b754cc9f0452bffe5a3ee7e7b93771d53809fbf7
|
16b4c31e577858036e293164412da35b11b3a5e3
|
refs/heads/master
| 2020-03-27T22:42:52.448584 | 2019-04-01T15:25:42 | 2019-04-01T15:25:42 | 147,254,277 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 6,640 |
c
|
route_task.c
|
/*
* $Id: route_task.c,v 1.1.1.1 2006/11/30 17:00:19 lizhijie Exp $
*/
#ifndef EXPORT_SYMTAB
#define EXPORT_SYMTAB
#endif
#include <linux/ip.h>
#include <linux/udp.h>
#include "mesh_route.h"
#include "_route.h"
static wait_queue_head_t aodv_wait;
static atomic_t kill_thread;
static atomic_t aodv_is_dead;
#if ROUTE_DEBUG
static char *_task_name[] =
{
"RREQ PDU",
"RREP PDU",
"RERR PDU",
"RREP ACK PDU",
"MGMT RESEND RREQ",
"MGMT HELLO",
"MGMT NEIGHBOR",
"MGMT CLEANUP",
"MGMT ROUTE CLEANUP"
};
#endif
/* remove task from queue and return, freed in aodvd thread, locked when free it */
static route_task_t *__aodv_task_get(route_engine_t *engine)
{
route_task_t *task, *tmp;
ROUTE_SPIN_LOCK(engine->taskLock);
/* it will be delete by kernel thread, so with safety */
ROUTE_LIST_FOR_EACH_SAFE(task, tmp, engine->tasks, list)
{
ROUTE_SPIN_UNLOCK(engine->taskLock);
return task;
}
ROUTE_SPIN_UNLOCK(engine->taskLock);
return NULL;
}
static int __aodv_route_flush(route_engine_t *engine)
{
mesh_route_t *route, *tmp;
unsigned long currtime = getcurrtime(engine->epoch);
unsigned long flags;
#if ROUTE_DEBUG
int count = 0;
#endif
ROUTE_WRITE_LOCK(engine->taskLock, flags);
ROUTE_LIST_FOR_EACH_SAFE(route, tmp, engine->routes, list)
{
if (time_before( route->lifetime, currtime) && (!route->self_route))
{
ROUTE_DPRINTF(engine, ROUTE_DEBUG_ROUTE, "looking at route: %s\n",inet_ntoa(route->ip));
if ( route->route_valid )
{
_route_expire( route);
}
else
{
// aodv_delete_kroute( route);
// ROUTE_WRITE_LOCK(engine->routeLock, flags);
ROUTE_LIST_DEL(&(route->list) );
kfree(route);
route = NULL;
count++;
// ROUTE_WRITE_UNLOCK( engine->routeLock, flags);
}
}
}
ROUTE_DPRINTF(engine, ROUTE_DEBUG_ROUTE, "%d route is deleted because of timerout\n", count);
ROUTE_WRITE_UNLOCK(engine->taskLock, flags);
return 0;
}
/* return the number of effected flood_id
flush all the expired flood_id and add a timer for for CLEANUP with length of HELLO_INTERVAL
*/
int __aodv_flood_flush(route_engine_t *engine)
{
route_flood_t *flood, *tmp;
unsigned long curr_time = getcurrtime(engine->epoch);
int count = 0;
unsigned long flags;
ROUTE_WRITE_LOCK(engine->floodLock, flags);
ROUTE_LIST_FOR_EACH_SAFE(flood, tmp, engine->floods, list)
{
if (time_before( flood->lifetime, curr_time))
{
ROUTE_LIST_DEL( &(flood->list) );
kfree( flood);
flood = NULL;
count++;
}
}
ROUTE_WRITE_UNLOCK(engine->floodLock, flags);
engine->mgmtOps->timer_insert(engine, ROUTE_TASK_CLEANUP, engine->myIp, HELLO_INTERVAL);
return count;
}
/* wakeup kernel thread when a task has enqueue task queue */
void kick_aodv()
{
wake_up_interruptible(&aodv_wait);
}
void kill_aodv()
{
wait_queue_head_t queue; /* wait queue for rmmod process */
init_waitqueue_head(&queue);
//sets a flag letting the thread know it should die
//wait for the thread to set flag saying it is dead
//lower semaphore for the thread
atomic_set(&kill_thread, 1);
wake_up_interruptible(&aodv_wait);
interruptible_sleep_on_timeout(&queue, HZ); /* block rmmod process tempate */
}
void aodv_kthread(void *data)
{
route_task_t *currentTask;
route_engine_t *engine = (route_engine_t *)data;
//Initalize the variables
init_waitqueue_head(&aodv_wait);
atomic_set(&kill_thread, 0);
atomic_set(&aodv_is_dead, 0);
lock_kernel();
sprintf(current->comm, "mrouted");
exit_mm(current);
unlock_kernel();
//add_wait_queue_exclusive(event_socket->sk->sleep,&(aodv_wait));
// add_wait_queue(&(aodv_wait),event_socket->sk->sleep);
for (;;)
{
if (atomic_read(&kill_thread))
{
goto exit;
}
//goto sleep until we recieve an interupt
interruptible_sleep_on(&aodv_wait);
if (atomic_read(&kill_thread))
{
goto exit;
}
while ((currentTask = __aodv_task_get(engine)) != NULL)
{
//takes a different action depending on what type of event is recieved
switch (currentTask->type)
{
case ROUTE_TASK_RREQ:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "RREQ\n");
engine->protoOps->rx_request(engine, currentTask);
kfree(currentTask->data);
break;
case ROUTE_TASK_RREP:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "RREP\n");
engine->protoOps->rx_reply(engine, currentTask);
kfree(currentTask->data);
break;
case ROUTE_TASK_RREP_ACK:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "RREP ACK\n");
engine->protoOps->rx_reply_ack(engine, currentTask);
kfree(currentTask->data);
break;
case ROUTE_TASK_RERR:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "RERR\n");
engine->protoOps->rx_error(engine, currentTask);
kfree(currentTask->data);
break;
//Cleanup the Route Table and Flood ID queue
case ROUTE_TASK_CLEANUP:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "CLEANUP\n");
__aodv_flood_flush(engine);
__aodv_route_flush(engine);
break;
case ROUTE_TASK_HELLO:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "HELLO\n");
engine->protoOps->send_hello(engine);
#ifdef ROUTE_SIGNAL
aodv_iw_get_stats(engine);
#endif
break;
case ROUTE_TASK_NEIGHBOR:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "NEIGH\n");
engine->mgmtOps->neigh_delete(engine, currentTask->src_ip);
break;
case ROUTE_TASK_ROUTE_CLEANUP:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "ROUTE CLEANUP\n");
__aodv_route_flush(engine);
break;
case ROUTE_TASK_RESEND_RREQ:
ROUTE_DPRINTF(engine, ROUTE_DEBUG_TASK, "TASK %s", "RESEND RREQ\n");
engine->protoOps->resend_request(engine, currentTask);
break;
default:
break;
}
ROUTE_SPIN_LOCK(engine->taskLock);
ROUTE_LIST_DEL(&(currentTask->list));
ROUTE_SPIN_UNLOCK(engine->taskLock);
kfree(currentTask);
currentTask = NULL;
}
}
exit:
//Set the flag that shows you are dead
atomic_set(&aodv_is_dead, 1);
}
/* create a task for both task queue and timer queue */
route_task_t *route_task_create(route_engine_t *engine, route_task_type_t type)
{
route_task_t *task;
task = (route_task_t *) kmalloc(sizeof(route_task_t), GFP_ATOMIC);
if ( task == NULL)
{
printk(KERN_WARNING "ERROR : Not enough memory to create Event Queue Entry\n");
return NULL;
}
task->time = getcurrtime(engine->epoch);
task->type = type;
task->src_ip = 0;
task->dst_ip = 0;
task->ttl = 0;
task->retries = 0;
task->data = NULL;
task->data_len = 0;
task->dev = NULL;
return task;
}
EXPORT_SYMBOL(route_task_create);
|
f206f9b053cf51ea18638d118d393868cdee73c0
|
1a4732a309689c3728299587f11c591eca997ad2
|
/includes/libui/ui_error.h
|
3ec03be8d1c7df8144c888802b095874e9e39539
|
[] |
no_license
|
agiordan101/doom_nukem
|
08dca55a7dbd5babe4cf944fb26b903b3722129c
|
2c4278b3475fe7d57a42bf71c51cb83ce62d0826
|
refs/heads/master
| 2021-07-22T09:48:18.856030 | 2020-06-10T20:32:25 | 2020-06-10T20:32:25 | 183,681,875 | 4 | 0 | null | 2019-04-26T19:13:54 | 2019-04-26T19:13:53 | null |
UTF-8
|
C
| false | false | 1,135 |
h
|
ui_error.h
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ui_error.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gal <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/21 18:17:22 by gmonacho #+# #+# */
/* Updated: 2020/05/19 09:27:46 by gal ### ########lyon.fr */
/* */
/* ************************************************************************** */
#ifndef UI_ERROR_H
# define UI_ERROR_H
int ui_ret_error(const char *function,
const char *error_msg,
int ret_value);
void *ui_ret_null_error(const char *function,
const char *error_msg,
void *return_value);
#endif
|
00667da9b1584b9b2f7453cb463af6b7ddedab05
|
976ee24af77af5aaac878c655d209385f0f8dc12
|
/tclinux_phoenix/modules/private/tc3162l2hp2h/tc3162_udc.h
|
77fa51784497a7cc435ceb7d6c5a003d242f6bf6
|
[] |
no_license
|
kdzm/tclinux
|
f628855fb9695897ddb8377ff515b44881df0ef1
|
aea3a43562e8d3dc0335624202fde08d713a18c2
|
refs/heads/master
| 2022-08-12T21:33:56.440685 | 2016-11-30T01:03:17 | 2016-11-30T01:03:17 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 29,180 |
h
|
tc3162_udc.h
|
//added by racing
#ifndef TC3162L2
#define TC3162L2
#endif
#ifndef BIG_ENDIAN
#define BIG_ENDIAN
#endif
#define USB_COST_DOWN_VERSION
//#define USE_USB_NEXT_LINK_PTR
//#define FAST_MBUF_RELEASE
#define DRIVER_NAME "tc3162_udc"
#define EP0_NAME "ep0"
#define EP1_NAME "ep1in-bulk"
#define EP2_NAME "ep2out-bulk"
#define EP3_NAME "ep3in-int"
#define NO_STATUS 0
#define STATUS 1
#define ACK_STATUS 2
#define NOACK_STATUS 3
#define TC3162_UDC_NUM_ENDPOINTS 4
#define MAX_FIFO_NUM 10
#define MAX_FIFO_HISTORY_NUM 1024
#define EP0_FIFO_SIZE 0x08
#define BULK_FIFO_SIZE ((unsigned)64)
#define INT_FIFO_SIZE ((unsigned)8)
#define USB_MAX_CTRL_ENDP_IN_QUE_SIZE 8
#define USB_CTRL_BUF_SIZE 0x100
#define BULK_IN 0
#define BULK_OUT 1
//#define NO_GADGET 1
#define GADGET_ETHER 1
#define GADGET_FILE_STORAGE 2
#define TRUE 1
#define FALSE 0
#define NONE 0
#define TEMPORARY 1
#define ORIGINAL 2
#define ON 1
#define OFF 0
#define SET_CONF 1
#define NOT_SET_CONF 0
#ifdef USB_COST_DOWN_VERSION
#define USB_DEVICE_PARAMETER_NUM 4
#else
#define USB_DEVICE_PARAMETER_NUM 19
#endif
#define USB_SOFTWARE 0
#define USB_HARDWARE 1
#define USB_BULK_ISO_IN_DESCP_NUM 32//64
#define USB_BULK_ISO_OUT_DESCP_NUM 16//32
#define littleToBig_32(n)(\
((((u32)(n))>>24)&0x000000ff)|\
((((u32)(n))>>8)&0x0000ff00)|\
((((u32)(n))<<8)&0x00ff0000)|\
((((u32)(n))<<24)&0xff000000))
#define littleToBig_16(n)(\
((((u16)(n))>>8)&0x00ff)|\
((((u16)(n))<<8)&0xff00))
#define NONE_STAGE 0
#define CTRL_MSG_RCVD 1
#define FIRST_OUT_MESG_RCVE 2
#define USB_EP0_PACKET_SIZE 0x08
#define USB_EP1_PACKET_SIZE 0x0040
#define USB_EP2_PACKET_SIZE 0x0040
#define USB_EP1_ALT0_PACKET_SIZE 0x0000
#define USB_EP2_ALT0_PACKET_SIZE 0x0000
#define USB_EP1_ALT1_PACKET_SIZE 0x0040
#define USB_EP2_ALT1_PACKET_SIZE 0x0040
#define USB_EP1_ALT2_PACKET_SIZE 0x0080
#define USB_EP2_ALT2_PACKET_SIZE 0x0080
#define USB_EP1_ALT3_PACKET_SIZE 0x0100
#define USB_EP2_ALT3_PACKET_SIZE 0x0100
#define USB_EP1_ALT4_PACKET_SIZE 0x0200
#define USB_EP2_ALT4_PACKET_SIZE 0x0200
#define USB_EP1_ALT5_PACKET_SIZE 0x0040
#define USB_EP2_ALT5_PACKET_SIZE 0x0040
#define USB_EP3_PACKET_SIZE 0x08
#define usbRegWrite4Byte(addr,val) ( *(volatile u32 *)(addr) = val )
#define usbRegWrite2Byte(addr,val) ( *(volatile uint16 *)(addr) = val )
#define usbRegWrite1Byte(addr,val) ( *(volatile uint8 *)(addr) = val )
#define usbRegRead4Byte(addr,val) ( val = *(volatile u32 *)(addr) )
#define usbRegRead2Byte(addr,val) ( val = *(volatile uint16 *)(addr))
#define usbRegRead1Byte(addr,val) ( val = *(volatile uint8 *)(addr) )
/* defined RNDIS and MAC Driver*/
#define RNDISDriver 1
#define MacDriver 2
#define MACFORTRENCHUP 3
struct tc3162_request {
int index;
struct usb_request req;
struct list_head queue;
};
struct tc3162_ep {
struct usb_ep ep;
struct tc3162_udc *dev;
const struct usb_endpoint_descriptor *desc;
struct list_head queue;
u8 bmAttributes;
};
struct tc3162_udc {
struct usb_gadget gadget;
struct usb_gadget_driver *driver;
struct tc3162_ep ep[TC3162_UDC_NUM_ENDPOINTS];
spinlock_t lock;
};
struct tc3162_task_param {
struct usb_ep ep;
struct usb_request req;
};
typedef struct usbFifoData_s {
u32 word[2];
u32 ctrl_ep_io_reg;
u32 rsv;
} usbFifoData_t;
typedef struct usbFifoHistory_s {
u32 word[2];
} usbFifoHistory_t;
typedef struct usbCtrlBuf_s {
uint8 data[USB_CTRL_BUF_SIZE];
u32 cnt;
} usbCtrlBuf_t;
typedef struct dmaBufferHeader_s{
dma_addr_t dmaHandle;
u32 bufSize;
char reserved[24];
}dmaBufferHeader_t;
#if 0
/*******************************************************************
TX/RX Buffer Descriptor Pool
*******************************************************************/
typedef struct usbInMemPool_s {
uint8 descrPool[USB_BULK_ISO_IN_DESCP_NUM * 16 + 16]; /* Descr pool area */
} usbInMemPool_t;
typedef struct usbOutMemPool_s {
uint8 descrPool[USB_BULK_ISO_OUT_DESCP_NUM * 16 + 16]; /* Descr pool area */
} usbOutMemPool_t;
#endif
/*******************************************************************
MACROs for REGISTER IO
*******************************************************************/
#define USB_SET_BULKISO_IN_DESCP_BASE_(x) \
*(volatile u32 *)(CR_USB_BULKISO_IN_DESCP_BASE_REG) = x;
#define USB_SET_BULKISO_OUT_DESCP_BASE_(x) \
*(volatile u32 *)(CR_USB_BULKISO_OUT_DESCP_BASE_REG) = x;
#define USB_GET_CONTROL_ENDPOINT_OUT_DATA_(H,L) \
L = *(volatile u32 *)(CR_USB_CTRL_ENDP_IO_OUT_REG0); \
H = *(volatile u32 *)(CR_USB_CTRL_ENDP_IO_OUT_REG1);
#define USB_SET_CONTROL_ENDPOINT_IN_DATA_(H,L) \
*(volatile u32 *)(CR_USB_CTRL_ENDP_IO_IN_REG0) = L; \
*(volatile u32 *)(CR_USB_CTRL_ENDP_IO_IN_REG1) = H;
#define USB_SET_INTERRUPT_ENDPOINT_IN_DATA_(H, L) \
*(volatile uint32 *)(CR_USB_INTR_IN_ENDP_IN_REG0) = L; \
*(volatile uint32 *)(CR_USB_INTR_IN_ENDP_IN_REG1) = H;
#define USB_SET_ISO_ENDP_DELIMITER_(H,L) \
*(volatile u32 *)(CR_USB_ISO_ENDP_DELIMITER_REG0) = L; \
*(volatile u32 *)(CR_USB_ISO_ENDP_DELIMITER_REG1) = (H&0x001fffff);
#define USB_SET_BULKISO_IN_OUT_ENDP_NUM_(IN,OUT) \
*(volatile u32 *)(CR_USB_BULKISO_INOUT_ENDP_NUM_REG) = \
((IN & 0x0000ffff) | ((OUT<<16) & 0xffff0000));
#define USB_IN_POLL_DEMAND_(x) \
x = *(volatile uint32 *)(CR_USB_BULKISO_ENDP_DMA_CTRL_REG) | 0x00000010; \
*(volatile uint32 *)(CR_USB_BULKISO_ENDP_DMA_CTRL_REG) = x;
#define USB_OUT_POLL_DEMAND_(x) \
x = *(volatile uint32 *)(CR_USB_BULKISO_ENDP_DMA_CTRL_REG) | 0x00001000; \
*(volatile uint32 *)(CR_USB_BULKISO_ENDP_DMA_CTRL_REG) = x;
#if !defined (K0_TO_K1)
#define K0_TO_K1(x) (((u32)(x)) | 0x20000000) /* kseg0 to kseg1 */
#endif
#if !defined (K1_TO_K0)
#define K1_TO_K0(x) (((u32)(x)) & 0x9fffffff) /* kseg1 to kseg0 */
#endif
#if !defined (K0_TO_PHYSICAL)
#define K0_TO_PHYSICAL(x) (((u32)(x)) & 0x1fffffff) /* kseg0 to physical */
#endif
#if !defined (K1_TO_PHYSICAL)
#define K1_TO_PHYSICAL(x) (((u32)(x)) & 0x1fffffff) /* kseg1 to physical */
#endif
#if !defined (PHYSICAL_TO_K0)
#define PHYSICAL_TO_K0(x) (((u32)(x)) | 0x80000000) /* physical to kseg0 */
#endif
#if !defined (PHYSICAL_TO_K1)
#define PHYSICAL_TO_K1(x) (((u32)(x)) | 0xa0000000) /* physical to kseg1 */
#endif
/*******************************************************************
USB SYSTEM CONTROL REGISTER
*******************************************************************/
typedef union _usb_sys_ctrl_reg
{
u32 value;
#ifdef BIG_ENDIAN
struct
{
unsigned pio_dma_reset : 1; // System Reset
unsigned rsv : 30; // Reserved
unsigned big_endian : 1; // Big Endian Mode
} bit;
#else // LITTLE_ENDIAN
struct
{
unsigned big_endian : 1; // Big Endian Mode
unsigned rsv : 30; // Reserved
unsigned pio_dma_reset : 1; // System Reset
} bit;
#endif
} usb_sys_ctrl_reg, *pusb_sys_ctrl_reg;
/*******************************************************************
USB DEVICE CONTROL REGISTER
*******************************************************************/
typedef union _usb_dev_ctrl_reg
{
u32 value;
#ifdef BIG_ENDIAN
struct
{
uint8 byte0;
uint8 byte1;
uint8 byte2;
uint8 byte3; // [31:0] == {byte0, byte1, byte2, byte3}
} byte;
struct
{
unsigned udc_dev_connect : 1; // UDC Device Connect (RW)
unsigned udc_dev_SIE_reset : 1; // UDC Device SIE Reset (RW)
unsigned udc_dev_resume : 1; // UDC Device Resume (RW)
unsigned rsv2 : 3; // Reserved
unsigned udc_cfg_read_done : 1; // UDC Configuration Dara Load Done (RO)
unsigned udc_cfg_writing : 1; // UDC Configuration Dara in writing (RO)
unsigned udc_cfg_data_port : 8; // UDC Alternative Interface Value (RW)
unsigned rsv1 : 1; // Reserved
unsigned udc_alt_setting : 3; // UDC Alternative Setting Value (RO)
unsigned udc_if_value : 2; // UDC Interface Value (RO)
unsigned udc_cfg_value : 2; // UDC Configuration Value (RO)
unsigned rsv0 : 1; // Reserved
unsigned udc_dev_addr : 7; // UDC Device Address (RO)
} bit;
#else // LITTLE_ENDIAN
struct
{
uint8 byte0;
uint8 byte1;
uint8 byte2;
uint8 byte3; // [31:0] == {byte3, byte2, byte1, byte0}
} byte;
struct
{
unsigned udc_dev_addr : 7; // UDC Device Address (RO)
unsigned rsv0 : 1; // Reserved
unsigned udc_cfg_value : 2; // UDC Configuration Value (RO)
unsigned udc_if_value : 2; // UDC Interface Value (RO)
unsigned udc_alt_setting : 3; // UDC Alternative Setting Value (RO)
unsigned rsv1 : 1; // Reserved
unsigned udc_cfg_data_port : 8; // UDC Alternative Interface Value (RW)
unsigned udc_cfg_writing : 1; // UDC Configuration Dara in writing (RO)
unsigned udc_cfg_read_done : 1; // UDC Configuration Dara Load Done (RO)
unsigned rsv2 : 3; // Reserved
unsigned udc_dev_resume : 1; // UDC Device Resume (RW)
unsigned udc_dev_SIE_reset : 1; // UDC Device SIE Reset (RW)
unsigned udc_dev_connect : 1; // UDC Device Connect (RW)
} bit;
#endif
} usb_dev_ctrl_reg, *pusb_dev_ctrl_reg;
/*******************************************************************
USB CONTROL ENDPOINT CONTROL REGISTER
*******************************************************************/
typedef union _usb_ctrl_endp_io_ctrl_reg
{
u32 value;
#ifdef BIG_ENDIAN
struct
{
uint8 byte0;
uint8 byte1;
uint8 byte2;
uint8 byte3;
} byte;
struct
{
unsigned ctrl_endp_out_Rx_data_cnt : 4;
unsigned ctrl_endp_in_Tx_data_cnt : 4;
unsigned ctrl_endp_out_stalled : 1;
unsigned ctrl_endp_in_stalled : 1;
unsigned out_token_Rx_data_owner : 1;
unsigned in_token_Tx_data_owner : 1;
unsigned rsv : 2;
unsigned ctrl_endp_stall : 1;
unsigned ctrl_endp_enable : 1;
unsigned ctrl_endp_number : 16;
} bit;
#else // LITTLE_ENDIAN
struct
{
uint8 byte0;
uint8 byte1;
uint8 byte2;
uint8 byte3;
} byte;
struct
{
unsigned ctrl_endp_number : 16;
unsigned ctrl_endp_enable : 1;
unsigned ctrl_endp_stall : 1;
unsigned rsv : 2;
unsigned in_token_Tx_data_owner : 1;
unsigned out_token_Rx_data_owner : 1;
unsigned ctrl_endp_in_stalled : 1;
unsigned ctrl_endp_out_stalled : 1;
unsigned ctrl_endp_in_Tx_data_cnt : 4;
unsigned ctrl_endp_out_Rx_data_cnt : 4;
} bit;
#endif
} usb_ctrl_endp_io_ctrl_reg, *pusb_ctrl_endp_io_ctrl_reg;
/*******************************************************************
USB BULK/ISO ENDPOINT CONTROL REGISTER
*******************************************************************/
typedef union _usb_bulkiso_endp_dma_ctrl_reg
{
u32 value;
#ifdef BIG_ENDIAN
struct
{
unsigned rsv3 : 17; // bit 15 ~ 31
unsigned bulkiso_out_DMA_reset : 1;
unsigned bulkiso_out_DMA_disable : 1;
unsigned bulkiso_out_DMA_enable : 1;
unsigned bulkiso_out_endp_stalled : 1;
unsigned rsv2 : 1; // bit 10
unsigned bulkiso_out_endp_stall : 1;
unsigned bulkiso_out_endp_enable : 1;
unsigned rsv1 : 1; // bit 7
unsigned bulkiso_in_DMA_reset : 1;
unsigned bulkiso_in_DMA_disable : 1;
unsigned bulkiso_in_DMA_enable : 1;
unsigned bulkiso_in_endp_stalled : 1;
unsigned rsv0 : 1; // bit 2
unsigned bulkiso_in_endp_stall : 1;
unsigned bulkiso_in_endp_enable : 1;
} bit;
#else // LITTLE_ENDIAN
struct
{
unsigned bulkiso_in_endp_enable : 1;
unsigned bulkiso_in_endp_stall : 1;
unsigned rsv0 : 1; // bit 2
unsigned bulkiso_in_endp_stalled : 1;
unsigned bulkiso_in_DMA_enable : 1;
unsigned bulkiso_in_DMA_disable : 1;
unsigned bulkiso_in_DMA_reset : 1;
unsigned rsv1 : 1; // bit 7
unsigned bulkiso_out_endp_enable : 1;
unsigned bulkiso_out_endp_stall : 1;
unsigned rsv2 : 1; // bit 10
unsigned bulkiso_out_endp_stalled : 1;
unsigned bulkiso_out_DMA_enable : 1;
unsigned bulkiso_out_DMA_disable : 1;
unsigned bulkiso_out_DMA_reset : 1;
unsigned rsv3 : 17; // bit 15 ~ 31
} bit;
#endif
} usb_bulkiso_endp_dma_ctrl_reg, *pusb_bulkiso_endp_dma_ctrl_reg;
/*******************************************************************
USB INTERRUPT MASK/STATUS REGISTER
*******************************************************************/
typedef union _usb_intr_reg
{
u32 value;
#ifdef BIG_ENDIAN
struct
{
unsigned SIE_bus_error : 1;
unsigned rsv1 : 10;
unsigned SIE_bus_host_resume_detected : 1;
unsigned SIE_set_interface_valid : 1;
unsigned SIE_set_configuration_valid : 1;
unsigned SIE_bus_reset_detected : 1;
unsigned SIE_bus_suspend_detected : 1;
unsigned rsv0 : 2;
unsigned intr_in_endp_transfer_nak : 1;
unsigned intr_in_endp_transfer_ack : 1;
unsigned bulk_iso_out_fifo_over_run : 1;
unsigned bulk_iso_out_end_of_descp : 1;
unsigned bulk_iso_out_buffer_not_ready : 1;
unsigned bulk_iso_out_endp_descp_updated : 1;
unsigned bulk_iso_in_fifo_under_run : 1;
unsigned bulk_iso_in_end_of_descp : 1;
unsigned bulk_iso_in_endp_descp_updated : 1;
unsigned ctrl_endp_setup_token_decoded : 1;
unsigned ctrl_endp_out_transfer_nak : 1;
unsigned ctrl_endp_out_transfer_ack : 1;
unsigned ctrl_endp_in_transfer_nak : 1;
unsigned ctrl_endp_in_transfer_ack : 1;
} bit;
#else // LITTLE_ENDIAN
struct
{
unsigned ctrl_endp_in_transfer_ack : 1;
unsigned ctrl_endp_in_transfer_nak : 1;
unsigned ctrl_endp_out_transfer_ack : 1;
unsigned ctrl_endp_out_transfer_nak : 1;
unsigned ctrl_endp_setup_token_decoded : 1;
unsigned bulk_iso_in_endp_descp_updated : 1;
unsigned bulk_iso_in_end_of_descp : 1;
unsigned bulk_iso_in_fifo_under_run : 1;
unsigned bulk_iso_out_endp_descp_updated : 1;
unsigned bulk_iso_out_buffer_not_ready : 1;
unsigned bulk_iso_out_end_of_descp : 1;
unsigned bulk_iso_out_fifo_over_run : 1;
unsigned intr_in_endp_transfer_ack : 1;
unsigned intr_in_endp_transfer_nak : 1;
unsigned rsv0 : 2;
unsigned SIE_bus_suspend_detected : 1;
unsigned SIE_bus_reset_detected : 1;
unsigned SIE_set_configuration_valid : 1;
unsigned SIE_set_interface_valid : 1;
unsigned SIE_bus_host_resume_detected : 1;
unsigned rsv1 : 10;
unsigned SIE_bus_error : 1;
} bit;
#endif
} usb_intr_status_reg, usb_intr_mask_reg,
*pusb_intr_status_reg, *pusb_intr_mask_reg;
enum _interrupt_bit_define
{
USB_CTRL_ENDP_IN_ACK = 0x00000001,
USB_CTRL_ENDP_IN_NAK = 0x00000002,
USB_CTRL_ENDP_OUT_ACK = 0x00000004,
USB_CTRL_ENDP_OUT_NAK = 0x00000008,
USB_CTRL_ENDP_SETUP_TOKEN_RCVED = 0x00000010, // default on
USB_BULKISO_ENDP_IN_DESCP_UPDATED = 0x00000020, // default on
USB_BULKISO_ENDP_IN_DESCP_END = 0x00000040,
USB_BULKISO_ENDP_IN_FIFO_UNDERRUN = 0x00000080,
USB_BULKISO_ENDP_OUT_DESCP_UPDATED = 0x00000100, // default on
USB_BULKISO_ENDP_OUT_BUF_BUSY = 0x00000200,
USB_BULKISO_ENDP_OUT_DESCP_END = 0x00000400,
USB_BULKISO_ENDP_OUT_FIFO_OVERRUN = 0x00000800,
USB_INTR_ENDP_IN_ACK = 0x00001000,
USB_INTR_ENDP_IN_NAK = 0x00002000,
USB_SIE_BUS_SUSPEND = 0x00010000, // default on
USB_SIE_BUS_RESET = 0x00020000, // default on
USB_SET_CONF_COMPLETE = 0x00040000, // default on
USB_SET_INF_COMPLETE = 0x00080000, // default on
USB_SIE_BUS_HOST_RESUME = 0x00100000,
USB_SIE_BUS_ERROR = 0x80000000 // default on
};
/*******************************************************************
USB BULK/ISO DMA DESCRIPTOR STRUCTURE
*******************************************************************/
typedef struct _usb_DMA_descp
{
#ifdef BIG_ENDIAN
union
{
u32 value;
struct
{
unsigned next_ptr : 30; // Next Link Pointer [31:2]
unsigned descp0_rsv : 1; // Reserved, [1]
unsigned terminator : 1; // T, [0]
} bit;
} NextLinkPointer;
union
{
u32 value;
struct
{
unsigned owner : 1; // Ownership, [31]
unsigned ioc : 1; // IOC, [30]
unsigned buf_unvalid : 1; // Buffer Not Available, [29]
unsigned retry_cnt : 2; // Retry Count, [28:27]
unsigned data_length : 11; // Data Length received in OUT, [26:16]
unsigned descp1_rsv0 : 5; // Reserved, [15:11]
unsigned buf_length : 11; // Buffer Length, [10:0]
} bit;
} DescpCommandStatus;
u32 BufferPointer;
u32 RequestPointer;
/*marked by racing
mbuf_t *MBufLinked;
*/
#else // LITTLE_ENDIAN
union
{
u32 value;
struct
{
unsigned terminator : 1; // T, [0]
unsigned descp0_rsv : 1; // Reserved, [1]
unsigned next_ptr : 30; // Next Link Pointer [31:2]
} bit;
} NextLinkPointer;
union
{
u32 value;
struct
{
unsigned buf_length : 11; // Buffer Length, [10:0]
unsigned descp1_rsv0 : 5; // Reserved, [15:11]
unsigned data_length : 11; // Data Length received in OUT, [26:16]
unsigned retry_cnt : 2; // Retry Count, [28:27]
unsigned buf_unvalid : 1; // Buffer Not Available, [29]
unsigned ioc : 1; // IOC, [30]
unsigned owner : 1; // Ownership, [31]
} bit;
} DescpCommandStatus;
u32 BufferPointer;
u32 RequestPointer;
#endif
} usb_dma_descp, *pusb_dma_descp;
/*******************************************************************
USB BULK/ISO ENDPOINT CONFIGURATION REGISTER
*******************************************************************/
typedef union _usb_bulkiso_endp_dma_conf_reg
{
u32 value;
#ifdef BIG_ENDIAN
struct
{
unsigned bulkiso_type_select : 1;
unsigned rsv1 : 1;
unsigned bulkiso_DMA_burst_size : 2;
unsigned bulkiso_out_threshold : 2;
unsigned bulkiso_in_threshold : 2;
unsigned rsv0 : 4;
unsigned bulkiso_out_max_pkt_size : 10;
unsigned bulkiso_in_max_pkt_size : 10;
} bit;
#else // LITTLE_ENDIAN
struct
{
unsigned bulkiso_in_max_pkt_size : 10;
unsigned bulkiso_out_max_pkt_size : 10;
unsigned rsv0 : 4;
unsigned bulkiso_in_threshold : 2;
unsigned bulkiso_out_threshold : 2;
unsigned bulkiso_DMA_burst_size : 2;
unsigned rsv1 : 1;
unsigned bulkiso_type_select : 1;
} bit;
#endif
} usb_bulkiso_endp_dma_conf_reg, *pusb_bulkiso_endp_dma_conf_reg;
/*******************************************************************
USB INTERRUPT IN ENDPOINT CONTROL REGISTER
*******************************************************************/
typedef union _usb_intr_in_endp_ctrl_reg
{
u32 value;
#ifdef BIG_ENDIAN
struct
{
unsigned rsv3 : 4;
unsigned intr_in_endp_Tx_data_cnt : 4;
unsigned rsv2 : 1;
unsigned intr_in_endp_stalled : 1;
unsigned rsv1 : 1;
unsigned in_token_Tx_data_owner : 1;
unsigned rsv0 : 2;
unsigned intr_in_endp_stall : 1;
unsigned intr_in_endp_enable : 1;
unsigned intr_in_endp_number : 16;
} bit;
#else
struct
{
unsigned intr_in_endp_number : 16;
unsigned intr_in_endp_enable : 1;
unsigned intr_in_endp_stall : 1;
unsigned rsv0 : 2;
unsigned in_token_Tx_data_owner : 1;
unsigned rsv1 : 1;
unsigned intr_in_endp_stalled : 1;
unsigned rsv2 stop_bulk_dma : 1;
unsigned intr_in_endp_Tx_data_cnt : 4;
unsigned rsv3 : 4;
} bit;
#endif
} usb_intr_in_endp_ctrl_reg, *pusb_intr_in_endp_ctrl_reg;
/****************************
* USB Module Registers *
****************************/
#define CR_USB_BASE 0xBFB70000
// --- System Control Register ---
#define CR_USB_SYS_CTRL_REG (0x00 | CR_USB_BASE)
// --- Device Control Register ---
#define CR_USB_DEV_CTRL_REG (0x04 | CR_USB_BASE)
// --- Interrupt Status Register ---
#define CR_USB_INTR_STATUS_REG (0x08 | CR_USB_BASE)
// --- Interrupt Mask Register ---
#define CR_USB_INTR_MASK_REG (0x0c | CR_USB_BASE)
// --- Control Endpoint I/O Mode Control Register ---
#define CR_USB_CTRL_ENDP_IO_CTRL_REG (0x10 | CR_USB_BASE)
// --- Control Endpoint I/O Mode OUT Transfer Data Register #00 ---
#define CR_USB_CTRL_ENDP_IO_OUT_REG0 (0x18 | CR_USB_BASE)
// --- Control Endpoint I/O Mode OUT Transfer Data Register #01 ---
#define CR_USB_CTRL_ENDP_IO_OUT_REG1 (0x1c | CR_USB_BASE)
// --- Control Endpoint I/O Mode IN Transfer Data Register #00 ---
#define CR_USB_CTRL_ENDP_IO_IN_REG0 (0x20 | CR_USB_BASE)
// --- Control Endpoint I/O Mode IN Transfer Data Register #01 ---
#define CR_USB_CTRL_ENDP_IO_IN_REG1 (0x24 | CR_USB_BASE)
// --- Interrupt IN Endpoint Control Register ---
#define CR_USB_INTR_IN_ENDP_CTRL_REG (0x30 | CR_USB_BASE)
// --- Interrupt IN Endpoint IN Transfer Data Register #00 ---
#define CR_USB_INTR_IN_ENDP_IN_REG0 (0x38 | CR_USB_BASE)
// --- Interrupt IN Endpoint IN Transfer Data Register #01 ---
#define CR_USB_INTR_IN_ENDP_IN_REG1 (0x3c | CR_USB_BASE)
// --- Bulk/ISO OUT Descriptor Pointer Register ---
#define CR_USB_BULKISO_OUT_DESCP_BASE_REG (0x40 | CR_USB_BASE)
// --- Bulk/ISO IN Descriptor Pointer Register ---
#define CR_USB_BULKISO_IN_DESCP_BASE_REG (0x44 | CR_USB_BASE)
// --- Bulk/ISO IN/OUT Endpoint Number Register ---
#define CR_USB_BULKISO_INOUT_ENDP_NUM_REG (0x48 | CR_USB_BASE)
// --- Bulk/ISO Endpoint DMA Control Register ---
#define CR_USB_BULKISO_ENDP_DMA_CTRL_REG (0x4c | CR_USB_BASE)
// --- Bulk/ISO Endpoint DMA Configuration Register ---
#define CR_USB_BULKISO_ENDP_DMA_CONF_REG (0x50 | CR_USB_BASE)
// --- ISO Endpoint Transfer Delimiter Register #00 ---
#define CR_USB_ISO_ENDP_DELIMITER_REG0 (0x58 | CR_USB_BASE)
// --- ISO Endpoint Transfer Delimiter Register #01 ---
#define CR_USB_ISO_ENDP_DELIMITER_REG1 (0x5c | CR_USB_BASE)
// --- Vendor ID Register ---
#define CR_USB_VENDOR_ID_REG (0x68 | CR_USB_BASE)
// --- Product ID Register ---
#define CR_USB_PRODUCT_ID_REG (0x6c | CR_USB_BASE)
#define CHK_BUF() pos = begin + index; if (pos < off) { index = 0; begin = pos; }; if (pos > off + count) goto done;
/**************************
* USB Module Registers *
**************************/
/*******************************************************************
FUNCTION DECLARATION
*******************************************************************/
static int tc3162_ep_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc);
static int tc3162_ep_disable (struct usb_ep *_ep);
static struct usb_request * tc3162_ep_alloc_request (struct usb_ep *_ep, gfp_t gfp_flags);
static void tc3162_ep_free_request (struct usb_ep *_ep, struct usb_request *_req);
static void * tc3162_ep_alloc_buffer(struct usb_ep *_ep, unsigned bytes, dma_addr_t *dma, gfp_t gfp_flags);
static void tc3162_ep_free_buffer(struct usb_ep *_ep, void *buf, dma_addr_t dma, unsigned bytes);
static int tc3162_ep_queue(struct usb_ep *_ep, struct usb_request *_req, gfp_t gfp_flags);
static int tc3162_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req);
static int tc3162_ep_set_halt(struct usb_ep *_ep, int value);
static int tc3162_ep_fifo_status(struct usb_ep *_ep);
static void tc3162_ep_fifo_flush(struct usb_ep *_ep);
static int tc3162_get_frame (struct usb_gadget *_gadget);
static int tc3162_wakeup (struct usb_gadget *_gadget);
static int tc3162_set_selfpowered (struct usb_gadget *_gadget, int value);
static int tc3162_pullup (struct usb_gadget *_gadget, int is_on);
static int tc3162_udc_probe(struct platform_device *pdev);
static int tc3162_udc_remove(struct platform_device *pdev);
void usbClearInterruptStatus (u32 status);
static u32 usbSetInterrupt (u32 unmask, int set);
static void usbDevConnect (int connectUSB);
static void usbCtrlEndpInAckTransfer (void);
static void usbReceiveOutPacket(void);
static void rtv_out_ack_data(void);
static int usbCtrlEndpInSend(int transfer_type);
static int usbSendInPacket (struct usb_request *req);
static void usbInPacketSent(void);
void usbInitBulkIso(void);
void *usbInitBulkIsoDMADescp (u32 numOfDescp, int type);
void* usbKmalloc(int size, int gfpFlag);
void usbKfree(void* addr);
void read_ctrl_ep_out_fifo(void);
void get_ctrl_ep_out_fifo_data(u32 *word0, u32 *word1, u32 *ctrl_ep_io_reg_v);
u8 get_next_fifo_len(void);
void dump_fifo_history(void);
void dump_descp_data(void *base_ptr, u32 numOfDescp);
int dump_count(int argc, char *argv[], void *p);
int desc_dump(int argc, char *argv[], void *p);
int fifo_dump(int argc, char *argv[], void *p);
int mem_dump(int argc, char *argv[], void *p);
void dump_data(u8 *data, int length);
void usbCtrlEndpTransfer(int transfer_type,u32 byte7654,u32 byte3210);
static void nop_release (struct device *dev);
void stop_and_clear_ep(void);
void clear_pool_data(void);
void reset_bulk_dma(void);
void reset_queue(void);
void usb_suspend(struct tc3162_udc *udc);
void stop_bulk_dma(void);
void init_parameters(void);
void init_hardware(void);
void init_dbg(void);
void stop_dbg(void);
int usb_stats_read_proc(char *buf, char **start, off_t off, int count,
int *eof, void *data);
int usb_stats_write_proc(struct file *file, const char *buffer,
unsigned long count, void *data);
int usb_link_stats_read_proc(char *buf, char **start, off_t off, int count,
int *eof, void *data);
void usbTimer(unsigned long data);
void clear_mib_count(void);
|
28b8bd836482826d6edb1ddc0ca87f87196273de
|
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
|
/source/micropython/ports/cc3200/fatfs/src/drivers/extr_sflash_diskio.c_sflash_disk_flush.c
|
7a897ecb64f0330ed6f5cbc4a536efb69671e47c
|
[] |
no_license
|
isabella232/AnghaBench
|
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
|
9a5f60cdc907a0475090eef45e5be43392c25132
|
refs/heads/master
| 2023-04-20T09:05:33.024569 | 2021-05-07T18:36:26 | 2021-05-07T18:36:26 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 960 |
c
|
extr_sflash_diskio.c_sflash_disk_flush.c
|
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef int /*<<< orphan*/ DRESULT ;
/* Variables and functions */
int /*<<< orphan*/ FS_MODE_OPEN_WRITE ;
int /*<<< orphan*/ RES_ERROR ;
int /*<<< orphan*/ RES_OK ;
int /*<<< orphan*/ sflash_access (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
int sflash_cache_is_dirty ;
int /*<<< orphan*/ sl_FsWrite ;
DRESULT sflash_disk_flush (void) {
// Write back the cache if it's dirty
if (sflash_cache_is_dirty) {
if (!sflash_access(FS_MODE_OPEN_WRITE, sl_FsWrite)) {
return RES_ERROR;
}
sflash_cache_is_dirty = false;
}
return RES_OK;
}
|
f009743cc4696769b979ce433e98f35ffaecfe02
|
ee4838ceb10d677b8ca925e640185ebe5dc5d50c
|
/lib/jamlib/activity.c
|
d9bb5a7802239c7a2859d807b5f29752a655afa7
|
[
"MIT"
] |
permissive
|
donatKapesa/JAMScript
|
f8c78c34330ced150cbdc9501130d40125462adc
|
fadf04ecb642b1cd6d173f09345b916ce422324e
|
refs/heads/master
| 2020-08-24T22:28:49.574142 | 2020-05-02T03:48:56 | 2020-05-02T03:48:56 | 216,918,566 | 1 | 2 |
NOASSERTION
| 2019-10-22T22:10:31 | 2019-10-22T22:10:31 | null |
UTF-8
|
C
| false | false | 22,319 |
c
|
activity.c
|
/*
The MIT License (MIT)
Copyright (c) 2016 Muthucumaru Maheswaran
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 <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
#ifdef __APPLE__
#include <mach/mach.h>
#include <mach/mach_time.h>
#endif
#ifdef linux
#include <time.h>
#endif
#include <task.h>
#include <sys/time.h>
#include "activity.h"
#include "nvoid.h"
#include "comboptr.h"
#include "jam.h"
//
// jactivity is created as follows:
// = created for the main thread - main program - this
// used to run the program and all the synchronous functions
// = created for each asynchronous functions
// = created for each remote function call
// jactivity is deleted as follows:
// = main thread is only deleted when the program is terminated
// = asynchronous functions - deleted by the user program
// = deleted by the remote function call
// What happens at creation?
// = Allocate memory for the activity structure
// = Get a free thread from the pool
// = Set the thread to the activity
// = Activity ID should be set in both thread and activity structures
// = State is set to NEW in the activity
// What happens at deletion?
// = Disassociate the thread from the activity: needs to be done in the thread and activity
// = Release activity ID by releasing the memory and setting the pointer to NULL
//
char *activity_gettime(char *prefix)
{
char buf[64];
#ifdef __APPLE__
if (prefix == NULL)
sprintf(buf, "%llu", mach_absolute_time());
else
sprintf(buf, "%s%llu", prefix, mach_absolute_time());
return strdup(buf);
#endif
#ifdef linux
struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp);
if (prefix == NULL)
sprintf(buf, "%li%li", tp.tv_sec, tp.tv_nsec);
else
sprintf(buf, "%s%li%li", prefix, tp.tv_sec, tp.tv_nsec);
return strdup(buf);
#endif
return 0;
}
long long activity_getseconds()
{
struct timeval tp;
if (gettimeofday(&tp, NULL) < 0)
{
printf("ERROR!! Getting system time..");
return 0;
}
return tp.tv_sec * 1000000LL + tp.tv_usec;
}
long activity_getuseconds()
{
struct timeval tp;
if (gettimeofday(&tp, NULL) < 0)
{
printf("ERROR!! Getting system time..");
return 0;
}
return tp.tv_usec;
}
activity_table_t *activity_table_new(void *jarg)
{
int i;
activity_table_t *atbl = (activity_table_t *)calloc(1, sizeof(activity_table_t));
assert(atbl != NULL);
//
// TODO: Is this back pointer necessary?
atbl->jarg = jarg;
atbl->jcounter = 1;
atbl->numcbackregs = 0;
for (i = 0; i < MAX_CALLBACKS; i++)
atbl->callbackregs[i] = NULL;
for (i = 0; i < MAX_ACT_THREADS; i++)
atbl->athreads[i] = athread_init(atbl);
// globalinq is used by the main thread for input purposes
// globaloutq is used by the main thread for output purposes
atbl->globalinq = p2queue_new(false);
atbl->globaloutq = queue_new(false);
// create the linked list to hold the activities
atbl->alist = create_list();
pthread_mutex_init(&(atbl->lock), NULL);
return atbl;
}
void activity_printthread(activity_thread_t *ja)
{
printf("\n");
printf("Activity ID: %d\n", ja->threadid);
printf("Activity state: %d\n", ja->jindx);
printf("\n");
}
void activity_table_print(activity_table_t *at)
{
int i;
printf("\n");
printf("Activity callback regs.: [%d] \n", at->numcbackregs);
printf("Registrations::\n");
for (i = 0; i < at->numcbackregs; i++)
activity_callbackreg_print(at->callbackregs[i]);
printf("Activity instances::\n");
for (i = 0; i < MAX_ACT_THREADS; i++)
activity_printthread(at->athreads[i]);
printf("\n");
}
void activity_callbackreg_print(activity_callback_reg_t *areg)
{
printf("\n");
printf("Activity reg. name: %s\n", areg->name);
printf("Activity reg. mask: %s\n", areg->signature);
printf("Activity reg. type: %d\n", areg->type);
printf("\n");
}
bool activity_regcallback(activity_table_t *at, char *name, int type, char *sig, activitycallback_f cback)
{
int i;
// if a registration already exists, return false
pthread_mutex_lock(&(at->lock));
for (i = 0; i < at->numcbackregs; i++)
if (strcmp(at->callbackregs[i]->name, name) == 0)
{
pthread_mutex_unlock(&(at->lock));
return false;
}
pthread_mutex_unlock(&(at->lock));
// otherwise, make a new activity registration.
activity_callback_reg_t *creg = (activity_callback_reg_t *)calloc(1, sizeof(activity_callback_reg_t));
strcpy(creg->name, name);
strcpy(creg->signature, sig);
creg->type = type;
creg->cback = cback;
pthread_mutex_lock(&(at->lock));
at->callbackregs[at->numcbackregs++] = creg;
pthread_mutex_unlock(&(at->lock));
#ifdef DEBUG_LVL1
printf("Activity make success: %s.. made\n", name);
#endif
return true;
}
activity_callback_reg_t *activity_findcallback(activity_table_t *at, char *name)
{
int i;
pthread_mutex_lock(&(at->lock));
for (i = 0; i < at->numcbackregs; i++)
{
if (strcmp(at->callbackregs[i]->name, name) == 0)
{
pthread_mutex_unlock(&(at->lock));
return at->callbackregs[i];
}
}
pthread_mutex_unlock(&(at->lock));
return NULL;
}
// This is the runner for the activity. Each activity is running this
// on its task. It loads the newly arriving request and starts the corresponding
// function
//
void run_activity(void *arg)
{
activity_table_t *at = ((comboptr_t *)arg)->arg1;
activity_thread_t *athread = ((comboptr_t *)arg)->arg2;
free(arg);
jamstate_t *js = (jamstate_t *)at->jarg;
activity_callback_reg_t *areg;
athread->taskid = taskid();
jactivity_t *jact;
while (1)
{
arg_t *repcode = NULL;
command_t *cmd;
nvoid_t *nv = pqueue_deq(athread->inq);
// The jactivity that is assigned to the the thread is in 'jactid'
int jindx = athread->jindx;
// Something is wrong.. we just got a spurious thread wakeup ... why??
if (jindx == 0)
continue;
// Get the command that woke up the thread.. this has the work to do
if (nv != NULL)
{
cmd = (command_t *)nv->data;
free(nv);
} else
cmd = NULL;
if (cmd != NULL)
{
jact = activity_getbyindx(at, jindx);
if (jact == NULL)
continue;
// If the activity is local.. we check whether this is servicing JSYNC task processing
if ((!jact->remote) && (strcmp(cmd->cmd, "LEXEC-ASY") == 0))
{
activity_callback_reg_t *creg = activity_findcallback(js->atable, cmd->actname);
creg->cback(jact, cmd);
activity_free(jact);
}
else
if ((!jact->remote) && jact->type == SYNC_RTE)
{
jam_clear_timer(js, jact->actid);
// We got the ack for the SYNC request..
if ((strcmp(cmd->cmd, "TIMEOUT") != 0) && (strcmp(cmd->cmd, "REXEC-NAK") != 0))
{
// We received the acknowledgement for the SYNC.. now proceed to the next stage.
int timeout = 900;
printf("------------------1--------\n");
jam_set_timer(js, jact->actid, timeout);
nv = pqueue_deq(athread->inq);
jam_clear_timer(js, jact->actid);
cmd = NULL;
if (nv != NULL)
{
cmd = (command_t *)nv->data;
free(nv);
if (strcmp(cmd->cmd, "REXEC-RES") == 0)
{
// We create a structure to hold the result returned by the root
repcode = (arg_t *)calloc(1, sizeof(arg_t));
command_arg_copy(repcode, &(cmd->args[0]));
// Push the reply.. into the reply queue..
pqueue_enq(athread->resultq, repcode, sizeof(arg_t));
} else
pqueue_enq(athread->resultq, NULL, 0);
} else
pqueue_enq(athread->resultq, NULL, 0);
}
else
{
// We did not receive the ack.. so we generate a NULL reply and push it to
// the reply queue.
pqueue_enq(athread->resultq, NULL, 0);
}
}
else
if ((!jact->remote) && jact->type == SYNC_NRT)
{
jam_clear_timer(js, jact->actid);
bool ack_failed = false;
for (int i = 0; i < machine_height(js) -1; i++)
{
if ((strcmp(cmd->cmd, "TIMEOUT") == 0) || (strcmp(cmd->cmd, "REXEC-NAK") == 0))
ack_failed = true;
if (i < machine_height(js) -2)
{
int timeout = 300;
printf("------------------2--------\n");
jam_set_timer(js, jact->actid, timeout);
nv = pqueue_deq(athread->inq);
jam_clear_timer(js, jact->actid);
if (nv != NULL)
{
cmd = (command_t *)nv->data;
free(nv);
}
}
}
int results;
if (!ack_failed)
results = 1;
else
results = 0;
pqueue_enq(athread->resultq, &results, sizeof(int));
}
else
if ((!jact->remote) && jact->type == ASYNC)
{
jam_clear_timer(js, jact->actid);
bool ack_failed = false;
for (int i = 0; i < machine_height(js) -1 ; i++)
{
if ((strcmp(cmd->cmd, "TIMEOUT") == 0) || (strcmp(cmd->cmd, "REXEC-NAK") == 0))
ack_failed = true;
if (i < machine_height(js) -2)
{
int timeout = 300;
printf("------------------3--------\n");
jam_set_timer(js, jact->actid, timeout);
nv = pqueue_deq(athread->inq);
jam_clear_timer(js, jact->actid);
if (nv != NULL)
{
cmd = (command_t *)nv->data;
free(nv);
}
}
}
int results;
if (!ack_failed)
results = 1;
else
results = 0;
pqueue_enq(athread->resultq, &results, sizeof(int));
}
else
{
if (strcmp(cmd->cmd, "REXEC-ASY") == 0)
{
areg = activity_findcallback(at, cmd->actname);
if (areg == NULL)
printf("Function not found.. %s\n", cmd->actname);
else
{
#ifdef DEBUG_LVL1
printf("Command actname = %s %s %s\n", cmd->actname, cmd->cmd, cmd->opt);
#endif
jrun_arun_callback(jact, cmd, areg);
#ifdef DEBUG_LVL1
printf(">>>>>>> After task create...cmd->actname %s\n", cmd->actname);
#endif
// Delete the runtable entry..
// TODO: Do we ever need a runtable entry (even the deleted one) at a later point in time?
runtable_del(js->rtable, cmd->actid);
}
}
else
if (strcmp(cmd->cmd, "REXEC-SYN") == 0)
{
// TODO: There is no difference at this point.. what will be the difference?
areg = activity_findcallback(at, cmd->actname);
if (areg == NULL)
printf("Function not found.. %s\n", cmd->actname);
else
{
#ifdef DEBUG_LVL1
printf("Command actname = %s %s %s\n", cmd->actname, cmd->cmd, cmd->opt);
#endif
jrun_arun_callback(jact, cmd, areg);
#ifdef DEBUG_LVL1
printf(">>>>>>> After task create...cmd->actname %s\n", cmd->actname);
#endif
// Delete the runtable entry..
// TODO: Do we ever need a runtable entry (even the deleted one) at a later point in time?
runtable_del(js->rtable, cmd->actid);
}
}
}
command_free(cmd);
}
// jindx = 0 means there is no active activity on the thread..
athread->jindx = 0;
taskyield();
}
}
// Create a new activity thread. This is reused by the system. That is,
// it is never released.
//
activity_thread_t *athread_init(activity_table_t *atbl)
{
static int counter = 0;
activity_thread_t *at = (activity_thread_t *)calloc(1, sizeof(activity_thread_t));
// Setup the dummy activity
at->jindx = 0;
at->threadid = counter++;
// Setup the I/O queues
at->inq = pqueue_new(false);
at->outq = queue_new(false);
at->resultq = pqueue_new(true);
comboptr_t *ct = create_combo3_ptr(atbl, at, NULL);
// TODO: What is the correct stack size? Remember this runs all user functions
taskcreate(run_activity, ct, 20000);
// return the pointer
return at;
}
activity_thread_t *athread_getmine(activity_table_t *at)
{
int i;
int myid = taskid();
// Get an EMPTY thread if available
pthread_mutex_lock(&(at->lock));
for (i = 0; i < MAX_ACT_THREADS; i++)
{
// thread found .. just return it.
if (at->athreads[i]->taskid == myid)
{
pthread_mutex_unlock(&(at->lock));
return at->athreads[i];
}
}
return NULL;
}
activity_thread_t *athread_get(activity_table_t *at, int jindx)
{
int i;
// Get an EMPTY thread if available
pthread_mutex_lock(&(at->lock));
for (i = 0; i < MAX_ACT_THREADS; i++)
{
// thread found .. just return it.
if (at->athreads[i]->jindx == jindx)
{
pthread_mutex_unlock(&(at->lock));
return at->athreads[i];
}
}
for (i = 0; i < MAX_ACT_THREADS; i++)
{
// Otherwise, find an empty thread..
if (at->athreads[i]->jindx == 0)
{
pthread_mutex_unlock(&(at->lock));
return at->athreads[i];
}
}
pthread_mutex_unlock(&(at->lock));
return NULL;
}
jactivity_t *activity_new(activity_table_t *at, char *actid, bool remote)
{
activity_thread_t *athr;
jactivity_t *jact = (jactivity_t *)calloc(1, sizeof(jactivity_t));
jact->atable = at;
jact->jindx = at->jcounter++;
int count = 3;
if (jact != NULL)
{
jact->remote = remote;
while ((athr = athread_get(at, jact->jindx)) == NULL)
{
taskdelay(10);
count--;
if (count <= 0)
{
if (odcount > ODCOUNT_MIN)
odcount -= ODCOUNT_DOWNVAL;
free(jact);
return NULL;
}
}
// Setup the thread.
pthread_mutex_lock(&(at->lock));
athr->jindx = jact->jindx;
pthread_mutex_unlock(&(at->lock));
strcpy(jact->actid, actid);
}
pthread_mutex_lock(&(at->lock));
put_list_tail(at->alist, jact, sizeof(jactivity_t));
pthread_mutex_unlock(&(at->lock));
// return the pointer
return jact;
}
jactivity_t *activity_renew(activity_table_t *at, jactivity_t *jact)
{
activity_thread_t *athr = athread_get(at, jact->jindx);
int count;
if (athr == NULL)
{
// The activity does not have a thread .. we need renewal
while ((athr = athread_get(at, jact->jindx)) == NULL)
{
taskdelay(10);
// Wait until we get a thread..
count--;
if (count <= 0)
{
if (odcount > ODCOUNT_MIN)
odcount -= ODCOUNT_DOWNVAL;
return NULL;
}
}
// Setup the thread.
pthread_mutex_lock(&(at->lock));
athr->jindx = jact->jindx;
pthread_mutex_unlock(&(at->lock));
return jact;
}
else
if (athr->jindx == jact->jindx)
return jact;
else
{
// Setup the thread.
pthread_mutex_lock(&(at->lock));
athr->jindx = jact->jindx;
pthread_mutex_unlock(&(at->lock));
return jact;
}
}
void activity_free(jactivity_t *jact)
{
if (jact == NULL)
return;
// Get a reference to the activity table..
activity_table_t *at = jact->atable;
pthread_mutex_lock(&(at->lock));
del_list_item(at->alist, jact);
pthread_mutex_unlock(&(at->lock));
// TODO: Could there be a need for flushing?
// Looks like we are having a "race" condition with flushing
//
// Get the thread held by the activity
// activity_thread_t *athr = athread_get(at, jact->jindx);
//
// if (athr->jindx > 0)
// {
// printf("Flusing activity jindx %d.. threadid %d \n", athr->jindx, athr->threadid);
// // We need to flush
// command_t *tmsg = command_new("FLUSH", "-", "-", 0, "ACTIVITY", jact->actid, "__", "");
// pqueue_enq(athr->inq, tmsg, sizeof(command_t));
// printf(".........Flusing activity jindx %d.. threadid %d \n", athr->jindx, athr->threadid);
// }
if (odcount < ODCOUNT_MAX)
odcount += ODCOUNT_UPVAL;
free(jact);
}
activity_thread_t *athread_getbyindx(activity_table_t *at, int jindx)
{
// Only return non NULL if the activity has a thread
activity_thread_t *athr = athread_get(at, jindx);
if (athr->jindx == jindx)
return athr;
else
return NULL;
}
int match_actid(void *elem, void *arg)
{
jactivity_t *jact = (jactivity_t *)elem;
if (jact == NULL)
return -1;
return strcmp(jact->actid, (char *)arg);
}
activity_thread_t *athread_getbyid(activity_table_t *at, char *actid)
{
pthread_mutex_lock(&(at->lock));
jactivity_t *jact = search_item(at->alist, actid, match_actid);
pthread_mutex_unlock(&(at->lock));
if (jact == NULL)
return NULL;
// Only return non NULL if the activity has a thread
activity_thread_t *athr = athread_get(at, jact->jindx);
if (athr->jindx == jact->jindx)
return athr;
else
return NULL;
}
int match_jindx(void *elem, void *arg)
{
jactivity_t *jact = (jactivity_t *)elem;
if (jact == NULL)
return -1;
if (jact->jindx == *(int *)arg)
return 0;
else
return -1;
}
jactivity_t *activity_getbyid(activity_table_t *at, char *actid)
{
pthread_mutex_lock(&(at->lock));
jactivity_t *jact = search_item(at->alist, actid, match_actid);
pthread_mutex_unlock(&(at->lock));
if (jact == NULL)
return NULL;
// Only return non NULL if the activity has a thread
activity_thread_t *athr = athread_get(at, jact->jindx);
if (athr->jindx == jact->jindx)
return jact;
else
return NULL;
}
jactivity_t *activity_getbyindx(activity_table_t *at, int jindx)
{
jactivity_t *jact;
pthread_mutex_lock(&(at->lock));
jact = search_item(at->alist, (char *)&jindx, match_jindx);
pthread_mutex_unlock(&(at->lock));
return jact;
}
void activity_complete(activity_table_t *at, char *opt, char *actid, char *fmt, ...)
{
va_list args;
arg_t *qarg;
qarg = (arg_t *)calloc(1, sizeof(arg_t));
va_start(args, fmt);
// switch on fmt[0]. It should not be more than one character
switch (fmt[0])
{
case 's':
qarg->val.sval = strdup(va_arg(args, char *));
qarg->type = STRING_TYPE;
break;
case 'i':
qarg->val.ival = va_arg(args, int);
qarg->type = INT_TYPE;
break;
case 'd':
qarg->val.dval = va_arg(args, double);
qarg->type = DOUBLE_TYPE;
break;
}
va_end(args);
jamstate_t *js = (jamstate_t *)at->jarg;
runtableentry_t *re = runtable_find(js->rtable, actid);
if (re != NULL)
jwork_send_results(js, opt, re->actname, re->actid, qarg);
}
|
56aacfbdb19ce1c2803542712410c20f7e760dcf
|
c6087bfc2341509e3ab0b5dd3e8337acc98fce98
|
/后期归纳/指针复习归纳/数组和指针.c
|
9aa22f2a1967dfe5b23495a0228038e725af5272
|
[] |
no_license
|
wd34zc/C
|
e87af330ccd850c226afcc8c73b69f1e8cecccb6
|
fc3631e6825d0afb66b7c4ed5077ce46b8d87fd5
|
refs/heads/master
| 2021-06-15T10:26:09.842232 | 2017-04-06T08:12:43 | 2017-04-06T08:12:43 | 72,554,531 | 0 | 0 | null | null | null | null |
GB18030
|
C
| false | false | 363 |
c
|
数组和指针.c
|
/*
指针和数组
*/
#include<stdio.h>
void show(const int[][2]);
int main()
{
int a[3]={1,2,3};
int * pa;
pa = a;
int b[3][2]={{1,2},{4,5},{7,8}};
int (*pb)[2];
pb = b;
show(b);//多为函数的传递
return 0;
}
void show(const int (*a)[2])
{
for(int i=0;i<3;i++)
{
for(int j=0;j<2;j++)
printf("%d ",a[i][j]);
putchar('\n');
}
}
|
66d14369fad6bf5deef84208f4028aa63a8a7ad9
|
0c83f00a66d29f5ab643391710b8af6d330f3f04
|
/code/socket/socket_ctrl.c
|
79c56e6ee22b3197f19f1423e26aeb67ad3a929d
|
[] |
no_license
|
challengezcy/work_diary
|
9e1d670d5746cfac29ce861d809024904313ec05
|
79df34289754ec5319bc2daef94c7dfab57a468f
|
refs/heads/master
| 2021-01-19T21:28:58.123213 | 2014-01-03T10:11:27 | 2014-01-03T10:11:27 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,556 |
c
|
socket_ctrl.c
|
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/if_bridge.h>
#include <sys/ioctl.h>
#include <linux/sockios.h>
#include <string.h>
#include <net/if.h>
int main()
{
int sock_ioctl = -1;
int sock_ioctl2 = -1;
int sock_ioctl3 = -1;
int flag;
struct ifreq ifr;
sock_ioctl = socket(AF_LOCAL, SOCK_DGRAM, 0);
flag = fcntl(sock_ioctl, F_GETFD);
printf("flag 0x%x \n", flag);
fcntl(sock_ioctl, F_SETFD, fcntl(sock_ioctl, F_GETFD) | FD_CLOEXEC);
flag = fcntl(sock_ioctl, F_GETFD);
printf("flag 0x%x \n", flag);
flag = ioctl(sock_ioctl, SIOCBRDELBR, "br0");
printf("ioctl flag 0x%x \n", flag);
sock_ioctl2 = socket(AF_LOCAL, SOCK_DGRAM, 0);
flag = fcntl(sock_ioctl2, F_GETFD);
printf("flag 0x%x \n", flag);
strncpy(ifr.ifr_name, "eth1", sizeof(ifr.ifr_name));
ioctl(sock_ioctl2, SIOCGIFINDEX, &ifr);
printf("ifindex: %d \n", ifr.ifr_ifindex);
ioctl(sock_ioctl2, SIOCGIFFLAGS, &ifr);
printf("ifr_flags: 0x%x \n", ifr.ifr_flags);
sock_ioctl3 = socket(AF_LOCAL, SOCK_DGRAM, 0);
flag = fcntl(sock_ioctl3, F_GETFD);
printf("flag 0x%x \n", flag);
ioctl(sock_ioctl3, SIOCGIFINDEX, &ifr);
printf("ifindex: %d \n", ifr.ifr_ifindex);
ioctl(sock_ioctl3, SIOCGIFFLAGS, &ifr);
printf("ifr_flags: 0x%x \n", ifr.ifr_flags);
printf("sock_ioctl number: %d \n", sock_ioctl);
printf("sock_ioctl number: %d \n", sock_ioctl2);
printf("sock_ioctl number: %d \n", sock_ioctl3);
getchar();
close(sock_ioctl);
close(sock_ioctl2);
close(sock_ioctl3);
}
|
557e7d8ae306ef96ed8e09046c98480a869b4583
|
ed7189bcb31973648dca4cb9f0d67cb4653d0e70
|
/tests/posix/getcwd.c
|
f3ba8da18b6daa61b19c53ae92d9a271d0156118
|
[
"MIT"
] |
permissive
|
managarm/mlibc
|
6dedaa86ed74f26a52e300d97f6e5949bac0f93c
|
74efefb5e9e546adab60a5730d95165334d7ee15
|
refs/heads/master
| 2023-09-01T05:17:26.709378 | 2023-08-29T08:33:01 | 2023-08-29T08:33:01 | 63,353,495 | 717 | 173 |
MIT
| 2023-09-10T10:55:53 | 2016-07-14T16:46:51 |
C
|
UTF-8
|
C
| false | false | 394 |
c
|
getcwd.c
|
#include <assert.h>
#include <limits.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
int main() {
char buf[PATH_MAX];
char *ret = getcwd(buf, PATH_MAX);
assert(ret);
assert((strlen(ret) == strlen(buf)) && strlen(ret));
assert(!strcmp(ret, buf));
char *ret2 = getcwd(NULL, 0);
assert(ret2);
assert(strlen(ret2));
assert(!strcmp(ret, ret2));
free(ret2);
return 0;
}
|
c208136b00bde7e2ff9833b7924a5f72b19cc779
|
ac3888ee5c09f2e334a3343f8ecf910b581c1b38
|
/src/tests/image_formats.c
|
7d651fc0c786eed1d4b9ccff5b03b590bb3d65a6
|
[] |
no_license
|
asmeikal/cl-utils
|
d51f2095a8812e289451198a93cb7ede9e92abf7
|
9d55472615f66f6aa6157e2cbb1a1db453e1b531
|
refs/heads/master
| 2020-04-15T04:34:02.632754 | 2017-01-02T12:58:34 | 2017-01-02T12:58:34 | 50,532,983 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,044 |
c
|
image_formats.c
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Debug.h>
#include "mlclut.h"
#include "mlclut_descriptions.h"
#define DEBUG_MAIN "main"
int main(void)
{
cl_uint n_platforms, n_devices;
cl_platform_id *platforms = clut_getAllPlatforms(&n_platforms);
if (NULL == platforms) {
Debug_out(DEBUG_MAIN, "No platforms available.\n");
return EXIT_FAILURE;
}
printf("Total number of platforms: %d.\n", n_platforms);
cl_device_id *devices = NULL;
cl_uint i, j;
for (i = 0; i < n_platforms; ++i) {
printf("Printing supported image formats for platform #%d:\n", i+1);
devices = clut_getAllDevices(platforms[i], CL_DEVICE_TYPE_ALL, &n_devices);
if (NULL == devices) {
Debug_out(DEBUG_MAIN, "Platform #%d has no devices.\n", i+1);
continue;
}
printf("Platform #%d has %d devices.\n", i+1, n_devices);
for (j = 0; j < n_devices; ++j) {
printf("Printing supported image formats for device #%d:\n", j+1);
clut_printDeviceSupportedImageFormats(devices[j]);
}
printf("\n");
}
return 0;
}
|
4ca7325f395da7b2e923244186fcb3cfdb49a2c5
|
4054a250ae5db77119bfc5fd54de94675a3231ca
|
/src/digital_signature/vccrypt_digital_signature_verify.c
|
88a3a6538bb28653fc45c89036b1358f0dac6495
|
[
"MIT"
] |
permissive
|
hocktide/v-c-crypto
|
21c937421534191e29d152f1e173e7e2dbd40bd0
|
4f3d5f21cc62f4a92c7987abdbcaee2d652781ca
|
refs/heads/master
| 2022-09-10T13:13:25.771967 | 2020-05-14T03:26:13 | 2020-05-29T19:37:48 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,664 |
c
|
vccrypt_digital_signature_verify.c
|
/**
* \file vccrypt_digital_signature_verify.c
*
* Verify a message using a digital signature scheme.
*
* \copyright 2017 Velo Payments, Inc. All rights reserved.
*/
#include <cbmc/model_assert.h>
#include <string.h>
#include <vccrypt/digital_signature.h>
#include <vpr/abstract_factory.h>
#include <vpr/parameters.h>
/**
* \brief Verify a message, given a public key, a message, and a message length.
*
* \param context An opaque pointer to the
* vccrypt_digital_signature_context_t structure.
* \param signature The signature to verify.
* \param pub The public key to use for signature verification.
* \param message The input message.
* \param size The size of the message in bytes.
*
* \returns a status indicating success or failure.
* - \ref VCCRYPT_STATUS_SUCCESS on success.
* - a non-zero error code indicating failure.
*/
int vccrypt_digital_signature_verify(
vccrypt_digital_signature_context_t* context,
const vccrypt_buffer_t* signature, const vccrypt_buffer_t* pub,
const uint8_t* message, size_t message_size)
{
MODEL_ASSERT(context != NULL);
MODEL_ASSERT(context->options != NULL);
MODEL_ASSERT(
context->options->vccrypt_digital_signature_alg_verify != NULL);
MODEL_ASSERT(signature != NULL);
MODEL_ASSERT(signature->size == context->options->signature_size);
MODEL_ASSERT(pub != NULL);
MODEL_ASSERT(pub->size == context->options->public_key_size);
MODEL_ASSERT(message != NULL);
return context->options->vccrypt_digital_signature_alg_verify(
context, signature, pub, message, message_size);
}
|
50f1c472daffe8cfbb2175c989feb065147e1080
|
fd0b720a56c8f675deb8ce253e06f43e36c75de8
|
/digivote/VOTE/HLC/SRC/C_LABEL.C
|
bd9dddcc68ee0f99594587b2c8cdaddb95046082
|
[] |
no_license
|
mart-e/evoting-be
|
4a95bb822aaf595dc668391596a871c2bfbd211c
|
6180526a574b05f8ec53d5731059228c6032baa3
|
refs/heads/master
| 2016-09-05T10:07:41.707721 | 2014-05-27T20:49:55 | 2014-05-27T20:49:55 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,975 |
c
|
C_LABEL.C
|
/************************************************************/
/* Copyright Alcatel Bell Telephone 1991 */
/* */
/* */
/* Filename : C_LABEL.C */
/* */
/* Author : Jacky Cuylen. */
/* */
/* Date of creation : 13/05/1991 */
/* */
/* Functionality : get disk label in var dsklbl */
/* */
/* Last Reviewed by : */
/* */
/* Date of Last Review : */
/* */
/* Based on Change Req : */
/* */
/* Approved by : */
/* */
/* Date of Approval : */
/* */
/************************************************************/
/************************************************************/
/* */
/* AVAILABLE FUNCTIONS */
/* */
/* function_name author date */
/* */
/* ffirst.c J.C. 9/04/93 */
/* */
/************************************************************/
/************************************************************/
/* */
/* INCLUDE FILES */
/* */
/************************************************************/
#include <dos.h>
#include <errno.h>
#include "hlc.h"
c_label()
{
int ret;
struct find_t finfo;
char volname[12];
strcpy( finfo.name, " ");
ret = _dos_findfirst( "a:\*.*", (unsigned) _A_VOLID, &finfo);
strncpy( volname, finfo.name, 8);
if( finfo.name[8] == '.')
strncpy( &volname[8], &finfo.name[9], 3);
else
volname[8] = 0x00;
volname[11] = 0x00;
if( ( ret = prowtc( "dsklbl", 0, volname, 0)) != 0)
promsgd( "Could not write the shared data in dsklbl.");
return( 0);
}
|
9023f7cfb1a7777d70bcde4959f9b498e4c9893c
|
c3e5a8da4c78944fbf2e527d0466c1db6f4a03f9
|
/pi/asm/prt.c
|
7d7b3ef768a587b8dcf3b4b640b4aae0dbf5fc56
|
[
"MIT"
] |
permissive
|
rene-d/souvenirs
|
631bb285da37ea62d0ecfede152006fd2650a5dc
|
b899f5ae910f2ab42f2328cff38f6e0a51dc1c9a
|
refs/heads/master
| 2021-01-22T09:40:35.422180 | 2018-07-13T10:26:49 | 2018-07-13T10:26:49 | 75,480,790 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 400 |
c
|
prt.c
|
#include <std.h>
main()
{
FILE *stream;
int c;
unsigned long i=0;
stream=fopen("million.dec","rb");
while ( (c=fgetc(stream)) != EOF) {
if (i % 50 == 0) printf("\n%-5lu ", i/50+1);
else if (i % 5 == 0) {
putchar(' ');
if (i%2==0) putchar(' ');
}
putchar(c);
i++;
}
fclose(stream);
}
|
1bd87ac8a784bb985e82ffb1fffe72dcd5032088
|
cf4d9d09c3f6706703d8a210de76ccd713bf68d2
|
/libraries/MySensors/examples/MQTTClientGateway/MyMQTTClient.h
|
d34782527b6a2521936d06684f1d62d398e7341c
|
[] |
no_license
|
nikil511/Arduino
|
74d32d1c5b6e6d65acd1bec61586bbae2e99c072
|
26323e96b517d9d09784a6ce8c67a09231321e7e
|
refs/heads/development
| 2021-01-20T23:03:29.736970 | 2015-09-17T17:57:11 | 2015-09-17T17:57:11 | 42,418,743 | 7 | 2 | null | 2015-09-14T00:46:34 | 2015-09-14T00:46:33 | null |
UTF-8
|
C
| false | false | 5,831 |
h
|
MyMQTTClient.h
|
/*
The MySensors library adds a new layer on top of the RF24 library.
It handles radio network routing, relaying and ids.
Created by Henrik Ekblad <[email protected]>
Modified by Daniel Wiegert
Modified by Norbert Truchsess <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
*/
#ifndef MyMQTTClient_h
#define MyMQTTClient_h
//////////////////////////////////////////////////////////////////
#ifdef DEBUG
#define TCPDUMP // Dump TCP packages.
#endif
#define MQTT_FIRST_SENSORID 20 // If you want manually configured nodes below this value. 255 = Disable
#define MQTT_LAST_SENSORID 254 // 254 is max! 255 reserved.
#define MQTT_PREFIX "MyMQTT" // First prefix in MQTT tree, keep short!
#define MQTT_TOPIC_MASK "MyMQTT/+/+/+/+" // Topic mask the client will subscribe to. This ensures that it will not receive any sensor data send by sensors
// the following topic structure is assumed: MyMQTT/<node-id>/<child_id>/<sensor-type>/<cmd>
#define MQTT_SEND_SUBSCRIPTION 1 // Send empty payload (request) to node upon MQTT client subscribe request.
#define MQTT_CMD_SET "set" // command (see MQTT_TOPIC_MASK); mapped to C_SET command type of sensor network
#define MQTT_CMD_GET "get" // command (see MQTT_TOPIC_MASK); mapped to C_REQ command type of sensor network
#define MQTT_AUTH_REQUIRED // if your broker has anonymous access uncomment
#define MQTT_USER "user" // username on MQTT broker
#define MQTT_PWD "pwd" // password for MQTT username above
#define MQTT_CONN_ID "MySensors" // passed as id to the MQTT broker
// NOTE above : Beware to check if there is any length on payload in your incommingMessage code:
// Example: if (msg.type==V_LIGHT && strlen(msg.getString())>0) otherwise the code might do strange things.
//////////////////////////////////////////////////////////////////
char VAR_0[] PROGMEM = "TEMP"; //V_TEMP
char VAR_1[] PROGMEM = "HUM"; //V_HUM
char VAR_2[] PROGMEM = "LIGHT"; //V_LIGHT
char VAR_3[] PROGMEM = "DIMMER"; //V_DIMMER
char VAR_4[] PROGMEM = "PRESSURE"; //V_PRESSURE
char VAR_5[] PROGMEM = "FORECAST"; //V_FORECAST
char VAR_6[] PROGMEM = "RAIN"; //V_RAIN
char VAR_7[] PROGMEM = "RAINRATE"; //V_RAINRATE
char VAR_8[] PROGMEM = "WIND"; //V_WIND
char VAR_9[] PROGMEM = "GUST"; //V_GUST
char VAR_10[] PROGMEM = "DIRECTON"; //V_DIRECTON
char VAR_11[] PROGMEM = "UV"; //V_UV
char VAR_12[] PROGMEM = "WEIGHT"; //V_WEIGHT
char VAR_13[] PROGMEM = "DISTANCE"; //V_DISTANCE
char VAR_14[] PROGMEM = "IMPEDANCE"; //V_IMPEDANCE
char VAR_15[] PROGMEM = "ARMED"; //V_ARMED
char VAR_16[] PROGMEM = "TRIPPED"; //V_TRIPPED
char VAR_17[] PROGMEM = "WATT"; //V_WATT
char VAR_18[] PROGMEM = "KWH"; //V_KWH
char VAR_19[] PROGMEM = "SCENE_ON"; //V_SCENE_ON
char VAR_20[] PROGMEM = "SCENE_OFF"; //V_SCENE_OFF
char VAR_21[] PROGMEM = "HEATER"; //V_HEATER
char VAR_22[] PROGMEM = "HEATER_SW"; //V_HEATER_SW
char VAR_23[] PROGMEM = "LIGHT_LEVEL"; //V_LIGHT_LEVEL
char VAR_24[] PROGMEM = "VAR1"; //V_VAR1
char VAR_25[] PROGMEM = "VAR2"; //V_VAR2
char VAR_26[] PROGMEM = "VAR3"; //V_VAR3
char VAR_27[] PROGMEM = "VAR4"; //V_VAR4
char VAR_28[] PROGMEM = "VAR5"; //V_VAR5
char VAR_29[] PROGMEM = "UP"; //V_UP
char VAR_30[] PROGMEM = "DOWN"; //V_DOWN
char VAR_31[] PROGMEM = "STOP"; //V_STOP
char VAR_32[] PROGMEM = "IR_SEND"; //V_IR_SEND
char VAR_33[] PROGMEM = "IR_RECEIVE"; //V_IR_RECEIVE
char VAR_34[] PROGMEM = "FLOW"; //V_FLOW
char VAR_35[] PROGMEM = "VOLUME"; //V_VOLUME
char VAR_36[] PROGMEM = "LOCK_STATUS"; //V_LOCK_STATUS
char VAR_37[] PROGMEM = "LEVEL"; // S_DUST, S_LIGHT_LEVEL, ...
char VAR_38[] PROGMEM = "VOLTAGE"; //V_VOLTAGE
char VAR_39[] PROGMEM = "CURRENT"; //V_CURRENT
char VAR_40[] PROGMEM = "RGB"; //V_RGB
char VAR_41[] PROGMEM = ""; //
char VAR_42[] PROGMEM = ""; //
char VAR_43[] PROGMEM = ""; //
char VAR_44[] PROGMEM = ""; //
char VAR_45[] PROGMEM = ""; //
char VAR_46[] PROGMEM = ""; //
char VAR_47[] PROGMEM = ""; //
char VAR_48[] PROGMEM = ""; //
char VAR_49[] PROGMEM = ""; //
char VAR_50[] PROGMEM = ""; //
char VAR_51[] PROGMEM = ""; //
char VAR_52[] PROGMEM = ""; //
char VAR_53[] PROGMEM = ""; //
char VAR_54[] PROGMEM = ""; //
char VAR_55[] PROGMEM = ""; //
char VAR_56[] PROGMEM = ""; //
char VAR_57[] PROGMEM = ""; //
char VAR_58[] PROGMEM = ""; //
char VAR_59[] PROGMEM = ""; //
char VAR_60[] PROGMEM = "Started!\n"; //Custom for MQTTGateway
char VAR_61[] PROGMEM = "SKETCH_NAME"; //Custom for MQTTGateway
char VAR_62[] PROGMEM = "SKETCH_VERSION"; //Custom for MQTTGateway
char VAR_63[] PROGMEM = "UNKNOWN"; //Custom for MQTTGateway
//////////////////////////////////////////////////////////////////
PROGMEM const char *VAR_Type[] =
{ VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13,
VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19, VAR_20, VAR_21, VAR_22, VAR_23, VAR_24, VAR_25,
VAR_26, VAR_27, VAR_28, VAR_29, VAR_30, VAR_31, VAR_32, VAR_33, VAR_34, VAR_35, VAR_36, VAR_37,
VAR_38, VAR_39, VAR_40, VAR_41, VAR_42, VAR_43, VAR_44, VAR_45, VAR_46, VAR_47, VAR_48, VAR_49,
VAR_50, VAR_51, VAR_52, VAR_53, VAR_54, VAR_55, VAR_56, VAR_57, VAR_58, VAR_59, VAR_60, VAR_61,
VAR_62, VAR_63
};
char mqtt_prefix[] PROGMEM = MQTT_PREFIX;
#define S_FIRSTCUSTOM 60
#define TYPEMAXLEN 20
#define VAR_TOTAL (sizeof(VAR_Type)/sizeof(char *))-1
#define EEPROM_LATEST_NODE_ADDRESS ((uint8_t)EEPROM_LOCAL_CONFIG_ADDRESS)
//#define DSRTC // RTC Dallas support -> disable debug and use isp programmer to free memory
#endif
|
c53afaeaf5db86b9bf83763188d8aff67736a11a
|
976f5e0b583c3f3a87a142187b9a2b2a5ae9cf6f
|
/source/Provenance/Cores/Yabause/yabause/src/gtk/extr_yuifileentry.c_yui_file_entry_class_init.c
|
354df32954feee3c43e976e945f3ddc0fd02d009
|
[] |
no_license
|
isabella232/AnghaBench
|
7ba90823cf8c0dd25a803d1688500eec91d1cf4e
|
9a5f60cdc907a0475090eef45e5be43392c25132
|
refs/heads/master
| 2023-04-20T09:05:33.024569 | 2021-05-07T18:36:26 | 2021-05-07T18:36:26 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,857 |
c
|
extr_yuifileentry.c_yui_file_entry_class_init.c
|
#define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
typedef struct TYPE_3__ TYPE_1__ ;
/* Type definitions */
typedef int /*<<< orphan*/ YuiFileEntryClass ;
struct TYPE_3__ {int /*<<< orphan*/ get_property; int /*<<< orphan*/ set_property; } ;
typedef int /*<<< orphan*/ GParamSpec ;
/* Variables and functions */
TYPE_1__* G_OBJECT_CLASS (int /*<<< orphan*/ *) ;
int G_PARAM_READABLE ;
int G_PARAM_WRITABLE ;
int /*<<< orphan*/ PROP_GROUP ;
int /*<<< orphan*/ PROP_KEY ;
int /*<<< orphan*/ PROP_KEYFILE ;
int /*<<< orphan*/ g_object_class_install_property (TYPE_1__*,int /*<<< orphan*/ ,int /*<<< orphan*/ *) ;
int /*<<< orphan*/ * g_param_spec_pointer (char*,int /*<<< orphan*/ ,int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ yui_file_entry_get_property ;
int /*<<< orphan*/ yui_file_entry_set_property ;
__attribute__((used)) static void yui_file_entry_class_init (YuiFileEntryClass * klass) {
GParamSpec * param;
G_OBJECT_CLASS(klass)->set_property = yui_file_entry_set_property;
G_OBJECT_CLASS(klass)->get_property = yui_file_entry_get_property;
param = g_param_spec_pointer("key-file", 0, 0, G_PARAM_READABLE | G_PARAM_WRITABLE);
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_KEYFILE, param);
param = g_param_spec_pointer("group", 0, 0, G_PARAM_READABLE | G_PARAM_WRITABLE);
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_GROUP, param);
param = g_param_spec_pointer("key", 0, 0, G_PARAM_READABLE | G_PARAM_WRITABLE);
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_KEY, param);
}
|
bb6b36766165ab97fc88f3e75ec94a6b6f683ee2
|
87fd32e66b168483d9953569006c18895dafcfe2
|
/transport/owr_session.c
|
7c024b6e0bfa763acbfd049b809ce26e8379d384
|
[
"BSD-2-Clause"
] |
permissive
|
pliu6/webrtc-pi
|
2676ff9f1d87cf4b1efe6094ce8d2f357b941949
|
af08c05fab6a6a8d2d287718190f76a830f5e8d0
|
refs/heads/master
| 2021-01-10T20:06:27.268423 | 2015-03-08T21:23:39 | 2015-03-08T21:23:39 | 31,865,267 | 8 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 15,021 |
c
|
owr_session.c
|
/*
* Copyright (c) 2014, Ericsson AB. All rights reserved.
* Copyright (c) 2014, Centricular Ltd
* Author: Sebastian Dröge <[email protected]>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/
/*/
\*\ OwrSession
/*/
/**
* SECTION:owr_session
* @short_description: OwrSession
* @title: OwrSession
*
* OwrSession - Represents a connection used for a session of either media or data.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "owr_session.h"
#include "owr_candidate_private.h"
#include "owr_private.h"
#include "owr_session_private.h"
#include <string.h>
#define DEFAULT_DTLS_CLIENT_MODE FALSE
#define DEFAULT_DTLS_CERTIFICATE "(auto)"
#define DEFAULT_DTLS_KEY "(auto)"
#define OWR_SESSION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), OWR_TYPE_SESSION, OwrSessionPrivate))
G_DEFINE_TYPE(OwrSession, owr_session, G_TYPE_OBJECT)
struct _OwrSessionPrivate {
gboolean rtcp_mux;
gboolean dtls_client_mode;
gchar *dtls_certificate;
gchar *dtls_key;
gchar *dtls_peer_certificate;
GSList *local_candidates;
GSList *remote_candidates;
GSList *forced_remote_candidates;
gboolean gathering_done;
GClosure *on_remote_candidate;
};
enum {
SIGNAL_ON_NEW_CANDIDATE,
SIGNAL_ON_CANDIDATE_GATHERING_DONE,
LAST_SIGNAL
};
#define DEFAULT_RTCP_MUX FALSE
enum {
PROP_0,
PROP_DTLS_CLIENT_MODE,
PROP_DTLS_CERTIFICATE,
PROP_DTLS_KEY,
PROP_DTLS_PEER_CERTIFICATE,
N_PROPERTIES
};
static guint session_signals[LAST_SIGNAL] = { 0 };
static GParamSpec *obj_properties[N_PROPERTIES] = {NULL, };
static gboolean add_remote_candidate(GHashTable *args);
static void owr_session_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
{
OwrSessionPrivate *priv = OWR_SESSION(object)->priv;
switch (property_id) {
case PROP_DTLS_CLIENT_MODE:
priv->dtls_client_mode = g_value_get_boolean(value);
break;
case PROP_DTLS_CERTIFICATE:
if (priv->dtls_certificate)
g_free(priv->dtls_certificate);
priv->dtls_certificate = g_value_dup_string(value);
if (priv->dtls_certificate && (!priv->dtls_certificate[0]
|| g_strstr_len(priv->dtls_certificate, 5, "null"))) {
g_free(priv->dtls_certificate);
priv->dtls_certificate = NULL;
}
g_warn_if_fail(!priv->dtls_certificate
|| g_str_has_prefix(priv->dtls_certificate, "-----BEGIN CERTIFICATE-----"));
break;
case PROP_DTLS_KEY:
if (priv->dtls_key)
g_free(priv->dtls_key);
priv->dtls_key = g_value_dup_string(value);
if (priv->dtls_key && (!priv->dtls_key[0] || g_strstr_len(priv->dtls_key, 5, "null"))) {
g_free(priv->dtls_key);
priv->dtls_key = NULL;
}
g_warn_if_fail(!priv->dtls_key
|| g_str_has_prefix(priv->dtls_key, "-----BEGIN PRIVATE KEY-----")
|| g_str_has_prefix(priv->dtls_key, "-----BEGIN RSA PRIVATE KEY-----"));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
}
static void owr_session_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
{
OwrSessionPrivate *priv = OWR_SESSION(object)->priv;
switch (property_id) {
case PROP_DTLS_CLIENT_MODE:
g_value_set_boolean(value, priv->dtls_client_mode);
break;
case PROP_DTLS_CERTIFICATE:
g_value_set_string(value, priv->dtls_certificate);
break;
case PROP_DTLS_KEY:
g_value_set_string(value, priv->dtls_key);
break;
case PROP_DTLS_PEER_CERTIFICATE:
g_value_set_string(value, priv->dtls_peer_certificate);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
break;
}
}
static void owr_session_on_new_candidate(OwrSession *session, OwrCandidate *candidate)
{
OwrSessionPrivate *priv;
g_return_if_fail(session);
g_return_if_fail(candidate);
priv = session->priv;
g_warn_if_fail(!priv->gathering_done);
priv->local_candidates = g_slist_append(priv->local_candidates, g_object_ref(candidate));
}
static void owr_session_on_candidate_gathering_done(OwrSession *session)
{
g_return_if_fail(session);
session->priv->gathering_done = TRUE;
}
static void owr_session_finalize(GObject *object)
{
OwrSession *session = OWR_SESSION(object);
OwrSessionPrivate *priv = session->priv;
_owr_session_clear_closures(session);
if (priv->dtls_certificate)
g_free(priv->dtls_certificate);
if (priv->dtls_key)
g_free(priv->dtls_key);
if (priv->dtls_peer_certificate)
g_free(priv->dtls_peer_certificate);
g_slist_free_full(priv->local_candidates, (GDestroyNotify)g_object_unref);
g_slist_free_full(priv->remote_candidates, (GDestroyNotify)g_object_unref);
g_slist_free_full(priv->forced_remote_candidates, (GDestroyNotify)g_object_unref);
G_OBJECT_CLASS(owr_session_parent_class)->finalize(object);
}
static void owr_session_class_init(OwrSessionClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(OwrSessionPrivate));
klass->on_new_candidate = owr_session_on_new_candidate;
klass->on_candidate_gathering_done = owr_session_on_candidate_gathering_done;
/**
* OwrSession::on-new-candidate:
* @session: the object which received the signal
* @candidate: the candidate gathered
*
* Notify of a new gathered candidate for a #OwrSession.
*/
session_signals[SIGNAL_ON_NEW_CANDIDATE] = g_signal_new("on-new-candidate",
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(OwrSessionClass, on_new_candidate), NULL, NULL,
NULL, G_TYPE_NONE, 1, OWR_TYPE_CANDIDATE);
/**
* OwrSession::on-candidate-gathering-done:
* @session: the object which received the signal
*
* Notify that all candidates have been gathered for a #OwrSession
*/
session_signals[SIGNAL_ON_CANDIDATE_GATHERING_DONE] =
g_signal_new("on-candidate-gathering-done",
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(OwrSessionClass, on_candidate_gathering_done), NULL, NULL,
NULL, G_TYPE_NONE, 0);
gobject_class->set_property = owr_session_set_property;
gobject_class->get_property = owr_session_get_property;
gobject_class->finalize = owr_session_finalize;
obj_properties[PROP_DTLS_CLIENT_MODE] = g_param_spec_boolean("dtls-client-mode",
"DTLS client mode", "TRUE if the DTLS connection should be setup using client role.",
DEFAULT_DTLS_CLIENT_MODE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_DTLS_CERTIFICATE] = g_param_spec_string("dtls-certificate",
"DTLS certificate", "The X509 certificate to be used by DTLS (in PEM format)."
" Set to NULL or empty string to disable DTLS",
DEFAULT_DTLS_CERTIFICATE, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
obj_properties[PROP_DTLS_KEY] = g_param_spec_string("dtls-key",
"DTLS key", "The RSA private key to be used by DTLS (in PEM format)",
DEFAULT_DTLS_KEY, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
obj_properties[PROP_DTLS_PEER_CERTIFICATE] = g_param_spec_string("dtls-peer-certificate",
"DTLS peer certificate",
"The X509 certificate of the remote peer, used by DTLS (in PEM format)",
NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties(gobject_class, N_PROPERTIES, obj_properties);
}
static void owr_session_init(OwrSession *session)
{
OwrSessionPrivate *priv;
session->priv = priv = OWR_SESSION_GET_PRIVATE(session);
priv->dtls_client_mode = DEFAULT_DTLS_CLIENT_MODE;
priv->dtls_certificate = g_strdup(DEFAULT_DTLS_CERTIFICATE);
priv->dtls_key = g_strdup(DEFAULT_DTLS_KEY);
priv->dtls_peer_certificate = NULL;
priv->local_candidates = NULL;
priv->remote_candidates = NULL;
priv->forced_remote_candidates = NULL;
priv->gathering_done = FALSE;
priv->on_remote_candidate = NULL;
}
/**
* owr_session_add_remote_candidate:
* @session: the session on which the candidate will be added.
* @candidate: (transfer none): the candidate to add
*
* Adds a remote candidate for this session.
*
*/
void owr_session_add_remote_candidate(OwrSession *session, OwrCandidate *candidate)
{
GHashTable *args;
g_return_if_fail(session);
g_return_if_fail(candidate);
if (session->priv->rtcp_mux && _owr_candidate_get_component_type(candidate) == OWR_COMPONENT_TYPE_RTCP) {
g_warning("Trying to adding RTCP component on an rtcp_muxing session. Aborting");
return;
}
args = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(args, "session", session);
g_hash_table_insert(args, "candidate", candidate);
g_object_ref(session);
g_object_ref(candidate);
_owr_schedule_with_hash_table((GSourceFunc)add_remote_candidate, args);
}
/**
* owr_session_force_remote_candidate:
* @session: The session on which the candidate will be forced.
* @candidate: (transfer none): the candidate to forcibly set
*
* Forces the transport agent to use the given candidate. Calling this function will disable all
* further ICE processing. Keep-alives will continue to be sent.
*/
void owr_session_force_remote_candidate(OwrSession *session, OwrCandidate *candidate)
{
GHashTable *args;
g_return_if_fail(OWR_IS_SESSION(session));
g_return_if_fail(OWR_IS_CANDIDATE(candidate));
args = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(args, "session", session);
g_hash_table_insert(args, "candidate", candidate);
g_hash_table_insert(args, "forced", GINT_TO_POINTER(TRUE));
g_object_ref(session);
g_object_ref(candidate);
_owr_schedule_with_hash_table((GSourceFunc)add_remote_candidate, args);
}
/* Internal functions */
static gboolean add_remote_candidate(GHashTable *args)
{
OwrSession *session;
OwrSessionPrivate *priv;
OwrCandidate *candidate;
gboolean forced;
GSList **candidates;
GValue params[2] = { G_VALUE_INIT, G_VALUE_INIT };
g_return_val_if_fail(args, FALSE);
session = g_hash_table_lookup(args, "session");
candidate = g_hash_table_lookup(args, "candidate");
forced = GPOINTER_TO_INT(g_hash_table_lookup(args, "forced"));
g_return_val_if_fail(session && candidate, FALSE);
priv = session->priv;
candidates = forced ? &priv->forced_remote_candidates : &priv->remote_candidates;
if (g_slist_find(*candidates, candidate)) {
g_warning("Fail: remote candidate already added.");
goto end;
}
if (g_slist_find(priv->local_candidates, candidate)) {
g_warning("Fail: candidate is local.");
goto end;
}
*candidates = g_slist_append(*candidates, candidate);
g_object_ref(candidate);
if (priv->on_remote_candidate) {
g_value_init(¶ms[0], OWR_TYPE_SESSION);
g_value_set_object(¶ms[0], session);
g_value_init(¶ms[1], G_TYPE_BOOLEAN);
g_value_set_boolean(¶ms[1], forced);
g_closure_invoke(priv->on_remote_candidate, NULL, 2, (const GValue *)¶ms, NULL);
g_value_unset(¶ms[0]);
g_value_unset(¶ms[1]);
}
end:
g_object_unref(candidate);
g_object_unref(session);
g_hash_table_unref(args);
return FALSE;
}
void _owr_session_clear_closures(OwrSession *session)
{
if (session->priv->on_remote_candidate) {
g_closure_invalidate(session->priv->on_remote_candidate);
g_closure_unref(session->priv->on_remote_candidate);
session->priv->on_remote_candidate = NULL;
}
}
/* Private methods */
/**
* _owr_session_get_remote_candidates:
* @session:
*
* Must be called from the main thread
*
* Returns: (transfer none) (element-type OwrCandidate):
*
*/
GSList * _owr_session_get_remote_candidates(OwrSession *session)
{
g_return_val_if_fail(session, NULL);
return session->priv->remote_candidates;
}
/**
* _owr_session_get_forced_remote_candidates:
* @session:
*
* Must be called from the main thread
*
* Returns: (transfer none) (element-type OwrCandidate):
*
*/
GSList * _owr_session_get_forced_remote_candidates(OwrSession *session)
{
g_return_val_if_fail(OWR_IS_SESSION(session), NULL);
return session->priv->forced_remote_candidates;
}
/**
* _owr_session_set_on_remote_candidate:
* @session:
* @on_remote_candidate: (transfer full):
*
*/
void _owr_session_set_on_remote_candidate(OwrSession *session, GClosure *on_remote_candidate)
{
g_return_if_fail(session);
g_return_if_fail(on_remote_candidate);
if (session->priv->on_remote_candidate)
g_closure_unref(session->priv->on_remote_candidate);
session->priv->on_remote_candidate = on_remote_candidate;
g_closure_set_marshal(session->priv->on_remote_candidate, g_cclosure_marshal_generic);
}
void _owr_session_set_dtls_peer_certificate(OwrSession *session,
const gchar *certificate)
{
OwrSessionPrivate *priv;
g_return_if_fail(OWR_IS_SESSION(session));
priv = session->priv;
if (priv->dtls_peer_certificate)
g_free(priv->dtls_peer_certificate);
priv->dtls_peer_certificate = g_strdup(certificate);
g_warn_if_fail(!priv->dtls_peer_certificate
|| g_str_has_prefix(priv->dtls_peer_certificate, "-----BEGIN CERTIFICATE-----"));
g_object_notify(G_OBJECT(session), "dtls-peer-certificate");
}
|
32942c60d5ea678d7e90d94c29c4deb564b576ba
|
31ae38b00379dc500aac71f072856dac40c4ca27
|
/Xcode/Testing-swift/Pods/Headers/Private/XMPPFramework/XMPPvCardTempTel.h
|
7b18c9a43dd4058c34284271992ccc89802578b2
|
[
"BSD-Source-Code",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain"
] |
permissive
|
sujrd/XMPPFramework
|
dd863506ba5d5e181f4ed1e432a14562ce7b31e1
|
dba72e6dce082f6f5da4a7b74968d6689b20854f
|
refs/heads/master
| 2020-03-18T20:49:16.840960 | 2018-12-14T06:37:31 | 2018-12-14T06:37:31 | 135,240,500 | 0 | 2 | null | 2018-05-29T04:19:41 | 2018-05-29T04:19:41 | null |
UTF-8
|
C
| false | false | 56 |
h
|
XMPPvCardTempTel.h
|
../../../../../../Extensions/XEP-0054/XMPPvCardTempTel.h
|
7bf9c2b5c29a0579ba04e9bd7a4eedb3f4b48f05
|
51635684d03e47ebad12b8872ff469b83f36aa52
|
/external/gcc-12.1.0/gcc/testsuite/g++.dg/cpp0x/variadic-crash6.C
|
88009b765c21b4e5868c73035c5f22963cb2baf7
|
[
"LGPL-2.1-only",
"FSFAP",
"LGPL-3.0-only",
"GPL-3.0-only",
"GPL-2.0-only",
"GCC-exception-3.1",
"LGPL-2.0-or-later",
"Zlib",
"LicenseRef-scancode-public-domain"
] |
permissive
|
zhmu/ananas
|
8fb48ddfe3582f85ff39184fc7a3c58725fe731a
|
30850c1639f03bccbfb2f2b03361792cc8fae52e
|
refs/heads/master
| 2022-06-25T10:44:46.256604 | 2022-06-12T17:04:40 | 2022-06-12T17:04:40 | 30,108,381 | 59 | 8 |
Zlib
| 2021-09-26T17:30:30 | 2015-01-31T09:44:33 |
C
|
UTF-8
|
C
| false | false | 213 |
c
|
variadic-crash6.C
|
// PR c++/99063
// { dg-do compile { target c++11 } }
template <typename... T>
void f (T... n)
{
do
{
}
while (--n); // { dg-error "parameter packs not expanded with '...'" }
}
void g ()
{
f(3);
}
|
e72d130d67da6ae43d1b81f4f4dc0b5b947b8c6c
|
74c3a885749cd0dd69a5e1b46cff121bfa6d62ed
|
/FinalProject/offensiveStyle/offensiveStyle.h
|
3d5b991991dd32b0bfcd4593ac9cff425e725136
|
[] |
no_license
|
timLarocque/mobileRobotics1
|
e60e9bf4fe7d0ace6daf7c338d79ad733f53d2bc
|
09054b08b1bb41a3dc16411872b0b77a0c94bfd7
|
refs/heads/master
| 2021-01-19T08:17:54.023949 | 2017-04-28T02:30:54 | 2017-04-28T02:30:54 | 82,080,307 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 645 |
h
|
offensiveStyle.h
|
// Created on Wed Apr 12 2017
#ifndef OFFENSIVE_STYLE_H
#define OFFENSIVE_STYLE_H
// include statements
#include <stdio.h>
// defining all of the sensors
#define LMOTOR 3
#define RMOTOR 0
#define SHIELD 8
#define LANCE 1
#define LHAT 1
#define RHAT 0
#define GREEN 1
// Shield detection structure
typedef struct {
int xCentroid;
int yCentroid;
int size;
} Shield;
typedef struct {
int left;
int right;
} NormalizedSpeed;
// function declarations
Shield findShield();
void approachShield();
void acceptDefeat();
void moveLance();
NormalizedSpeed normalize(Shield target);
void avoid_border_left();
void avoid_border_right();
#endif
|
65b900de7a92f17b25df2470076a94343279d248
|
6123d4738c4697e034e34865b383e7229f98b8a6
|
/file3.c
|
294ba8c71a4fbd65a7e344653b756871e7d34ee3
|
[] |
no_license
|
mehnazhossain19/011162148_gitassignment_selab
|
84479662be33cea5eb65f1dc0639e9cf5cb483e7
|
062cf85248cbfcffc073c6e7f21d13864607df96
|
refs/heads/main
| 2023-05-14T20:29:38.980174 | 2021-06-06T16:29:01 | 2021-06-06T16:29:01 | 374,403,056 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 72 |
c
|
file3.c
|
#include<stdio.h>
int main(){
printf("file3 added in main branch");
}
|
2277486b12d7c42bd15dbedd971decb6a6ecff7a
|
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
|
/databases/mysql75-cluster/patches/patch-rapid_plugin_group__replication_libmysqlgcs_src_bindings_xcom_xcom_sock__probe__ix.c
|
965e37c71a5f726c1d7e81da0be15788ee958e97
|
[] |
no_license
|
NetBSD/pkgsrc
|
a0732c023519650ef821ab89c23ab6ab59e25bdb
|
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
|
refs/heads/trunk
| 2023-09-01T07:40:12.138283 | 2023-09-01T05:25:19 | 2023-09-01T05:25:19 | 88,439,572 | 321 | 138 | null | 2023-07-12T22:34:14 | 2017-04-16T20:04:15 | null |
UTF-8
|
C
| false | false | 712 |
c
|
patch-rapid_plugin_group__replication_libmysqlgcs_src_bindings_xcom_xcom_sock__probe__ix.c
|
$NetBSD: patch-rapid_plugin_group__replication_libmysqlgcs_src_bindings_xcom_xcom_sock__probe__ix.c,v 1.1 2022/04/17 04:07:14 jnemeth Exp $
--- rapid/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/sock_probe_ix.c.orig 2021-09-14 09:08:08.000000000 +0000
+++ rapid/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/sock_probe_ix.c
@@ -147,7 +147,7 @@ static int init_sock_probe(sock_probe *s
interfaces. We are doing this, since the size of sockaddr differs on
some platforms.
*/
- for (i= 0, ptr= s->ifc.ifc_buf, end= s->ifc.ifc_buf + s->ifc.ifc_len;
+ for (i= 0, ptr= (char *)s->ifc.ifc_buf, end= (char *)s->ifc.ifc_buf + s->ifc.ifc_len;
ptr<end;
i++)
{
|
a9280654a2c83109cae027382ae52dbe046e348b
|
604a6d7c37f1008f144d7b1c4550d83fb21ebf41
|
/lab3/DabrowaJedrzej-cw03/cw02/zad2/src/file_counter.c
|
d55a02b9d5a21a4687fde9cfc77f027c37fc95db
|
[] |
no_license
|
nachteil/sysopy
|
c4c55fb9656cab55392f57a50a67a269feb9a875
|
aed86de01e4ea15dbbc10c824dcbf5db0c34395b
|
refs/heads/master
| 2021-01-16T18:19:09.427251 | 2015-06-08T20:49:54 | 2015-06-08T20:49:54 | 33,031,275 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 4,062 |
c
|
file_counter.c
|
#include "file_counter.h"
#include "string.h"
#include "stdlib.h"
#include "stdio.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "unistd.h"
#include "dirent.h"
#include "errno.h"
#include "string.h"
#include "sys/wait.h"
int main(int argc, char *argv[]) {
int test_mode = 0;
int should_log = 0;
char *path;
if (argc == 4) {
if ((!strcmp(argv[1], "-v") && !strcmp(argv[2], "-w"))
|| (!strcmp(argv[1], "-w") && !strcmp(argv[2], "-v"))) {
test_mode = should_log = 1;
} else {
usage();
}
} else if (argc == 3) {
if (!strcmp(argv[1], "-wv") || !strcmp(argv[1], "-vw")) {
test_mode = 1;
should_log = 1;
} else if (!strcmp(argv[1], "-v")) {
should_log = 1;
} else if (!strcmp(argv[1], "-w")) {
test_mode = 1;
} else {
usage();
}
} else if (argc > 4 || argc < 2) {
usage();
}
if ((path = (char *) malloc(1024)) == NULL) {
printf("Memory allocation error\n");
exit(1);
}
strcpy(path, argv[argc - 1]);
// actual code starts here
DIR *dir;
struct dirent *dir_entry;
int num_processes = 0;
long pid;
int status;
int num_files = 0;
if ((dir = opendir(path)) == NULL) {
printf("%s is not a dir!\n", path);
exit(-1);
}
while ((dir_entry = readdir(dir)) != NULL) {
char *curr_file_name = dir_entry->d_name;
if (strcmp(curr_file_name, ".") && strcmp(curr_file_name, "..")) {
int path_len = strlen(path);
path[path_len++] = '/';
strcpy(&path[path_len], curr_file_name);
struct stat stat_buf;
if (lstat(path, &stat_buf) != 0) {
printf("Something went wrong in %s reading %s, won't go further\n", path, curr_file_name);
printf("Error: %d (%s)\n", errno, strerror(errno));
exit(-1);
}
if (S_ISDIR(stat_buf.st_mode)) {
num_processes += 1;
if ((pid = fork()) < 0) {
printf("Forking error at %s\n", path);
printf("Error message: %d - %s\n", errno, strerror(errno));
exit(-1);
} else if (pid == 0) {
errno = 0;
if (should_log || test_mode) {
char opts[3];
opts[0] = '-';
opts[1] = should_log ? 'v' : 'w';
opts[2] = test_mode && should_log ? 'w' : 0;
execl(argv[0], argv[0], opts, path, (char *) 0);
if (errno != 0) {
printf("Error on execl: %d - %s\n", errno, strerror(errno));
}
} else {
execl(argv[0], argv[0], path, (char *) 0);
if (errno != 0) {
printf("Error on execl: %d - %s\n", errno, strerror(errno));
}
}
}
} else if (S_ISREG(stat_buf.st_mode)) {
++num_files;
}
path[--path_len] = 0;
}
}
closedir(dir);
if (test_mode) {
sleep(10);
}
int child_files = 0;
while (num_processes--) {
wait(&status);
if (WEXITSTATUS(status) == -1) {
exit(-1);
} else {
child_files += WEXITSTATUS(status);
}
}
if (should_log) {
printf("%s, %d, %d\n", path, num_files, num_files + child_files);
}
exit(num_files + child_files);
}
void usage(void) {
printf("Wrong program arguments\n");
printf("Usage: file_counter <options> path, where <options> is any combination of the following:\n");
printf("\t-w - to enter test mode (make each process sleep for 10 seconds before terminating)\n");
printf("\t-v - enable logging (verbose mode)\n");
exit(1);
}
|
aa508986eedf739102d4453b2095c16ae4e81e53
|
bbab2cc5fc475d6ce9c9465e0b954ff5b0c75387
|
/subversion-1.6.13/subversion/libsvn_subr/properties.c
|
db5be9eccef740087fff0c4ab69ff331fc0322ee
|
[
"BSD-2-Clause"
] |
permissive
|
RussellBauer/G5_Deps
|
df4ddff82753281a500d44bcd18a4ba19d1fcf1e
|
8918d8ce8d15cc494f499859cfbfe8e66c574acc
|
refs/heads/master
| 2021-04-06T08:58:46.594961 | 2018-03-13T15:55:28 | 2018-03-13T15:55:28 | 125,070,934 | 0 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 7,668 |
c
|
properties.c
|
/*
* properties.c: stuff related to Subversion properties
*
* ====================================================================
* Copyright (c) 2000-2006 CollabNet. All rights reserved.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at http://subversion.tigris.org/license-1.html.
* If newer versions of this license are posted there, you may use a
* newer version instead, at your option.
*
* This software consists of voluntary contributions made by many
* individuals. For exact contribution history, see the revision
* history and logs, available at http://subversion.tigris.org/.
* ====================================================================
*/
#include <apr_pools.h>
#include <apr_hash.h>
#include <apr_tables.h>
#include <string.h> /* for strncmp() */
#include "svn_string.h"
#include "svn_props.h"
#include "svn_error.h"
#include "svn_ctype.h"
svn_boolean_t
svn_prop_is_svn_prop(const char *prop_name)
{
return strncmp(prop_name, SVN_PROP_PREFIX, (sizeof(SVN_PROP_PREFIX) - 1))
== 0;
}
svn_boolean_t
svn_prop_has_svn_prop(const apr_hash_t *props, apr_pool_t *pool)
{
apr_hash_index_t *hi;
const void *prop_name;
if (! props)
return FALSE;
for (hi = apr_hash_first(pool, (apr_hash_t *)props); hi;
hi = apr_hash_next(hi))
{
apr_hash_this(hi, &prop_name, NULL, NULL);
if (svn_prop_is_svn_prop((const char *) prop_name))
return TRUE;
}
return FALSE;
}
svn_prop_kind_t
svn_property_kind(int *prefix_len,
const char *prop_name)
{
apr_size_t wc_prefix_len = sizeof(SVN_PROP_WC_PREFIX) - 1;
apr_size_t entry_prefix_len = sizeof(SVN_PROP_ENTRY_PREFIX) - 1;
if (strncmp(prop_name, SVN_PROP_WC_PREFIX, wc_prefix_len) == 0)
{
if (prefix_len)
*prefix_len = wc_prefix_len;
return svn_prop_wc_kind;
}
if (strncmp(prop_name, SVN_PROP_ENTRY_PREFIX, entry_prefix_len) == 0)
{
if (prefix_len)
*prefix_len = entry_prefix_len;
return svn_prop_entry_kind;
}
/* else... */
if (prefix_len)
*prefix_len = 0;
return svn_prop_regular_kind;
}
svn_error_t *
svn_categorize_props(const apr_array_header_t *proplist,
apr_array_header_t **entry_props,
apr_array_header_t **wc_props,
apr_array_header_t **regular_props,
apr_pool_t *pool)
{
int i;
if (entry_props)
*entry_props = apr_array_make(pool, 1, sizeof(svn_prop_t));
if (wc_props)
*wc_props = apr_array_make(pool, 1, sizeof(svn_prop_t));
if (regular_props)
*regular_props = apr_array_make(pool, 1, sizeof(svn_prop_t));
for (i = 0; i < proplist->nelts; i++)
{
svn_prop_t *prop, *newprop;
enum svn_prop_kind kind;
prop = &APR_ARRAY_IDX(proplist, i, svn_prop_t);
kind = svn_property_kind(NULL, prop->name);
newprop = NULL;
if (kind == svn_prop_regular_kind)
{
if (regular_props)
newprop = apr_array_push(*regular_props);
}
else if (kind == svn_prop_wc_kind)
{
if (wc_props)
newprop = apr_array_push(*wc_props);
}
else if (kind == svn_prop_entry_kind)
{
if (entry_props)
newprop = apr_array_push(*entry_props);
}
else
/* Technically this can't happen, but might as well have the
code ready in case that ever changes. */
return svn_error_createf(SVN_ERR_BAD_PROP_KIND, NULL,
"Bad property kind for property '%s'",
prop->name);
if (newprop)
{
newprop->name = prop->name;
newprop->value = prop->value;
}
}
return SVN_NO_ERROR;
}
svn_error_t *
svn_prop_diffs(apr_array_header_t **propdiffs,
apr_hash_t *target_props,
apr_hash_t *source_props,
apr_pool_t *pool)
{
apr_hash_index_t *hi;
apr_array_header_t *ary = apr_array_make(pool, 1, sizeof(svn_prop_t));
/* Note: we will be storing the pointers to the keys (from the hashes)
into the propdiffs array. It is acceptable for us to
reference the same memory as the base/target_props hash. */
/* Loop over SOURCE_PROPS and examine each key. This will allow us to
detect any `deletion' events or `set-modification' events. */
for (hi = apr_hash_first(pool, source_props); hi; hi = apr_hash_next(hi))
{
const void *key;
apr_ssize_t klen;
void *val;
const svn_string_t *propval1, *propval2;
/* Get next property */
apr_hash_this(hi, &key, &klen, &val);
propval1 = val;
/* Does property name exist in TARGET_PROPS? */
propval2 = apr_hash_get(target_props, key, klen);
if (propval2 == NULL)
{
/* Add a delete event to the array */
svn_prop_t *p = apr_array_push(ary);
p->name = key;
p->value = NULL;
}
else if (! svn_string_compare(propval1, propval2))
{
/* Add a set (modification) event to the array */
svn_prop_t *p = apr_array_push(ary);
p->name = key;
p->value = svn_string_dup(propval2, pool);
}
}
/* Loop over TARGET_PROPS and examine each key. This allows us to
detect `set-creation' events */
for (hi = apr_hash_first(pool, target_props); hi; hi = apr_hash_next(hi))
{
const void *key;
apr_ssize_t klen;
void *val;
const svn_string_t *propval;
/* Get next property */
apr_hash_this(hi, &key, &klen, &val);
propval = val;
/* Does property name exist in SOURCE_PROPS? */
if (NULL == apr_hash_get(source_props, key, klen))
{
/* Add a set (creation) event to the array */
svn_prop_t *p = apr_array_push(ary);
p->name = key;
p->value = svn_string_dup(propval, pool);
}
}
/* Done building our array of user events. */
*propdiffs = ary;
return SVN_NO_ERROR;
}
svn_boolean_t
svn_prop_is_boolean(const char *prop_name)
{
/* If we end up with more than 3 of these, we should probably put
them in a table and use bsearch. With only three, it doesn't
make any speed difference. */
if (strcmp(prop_name, SVN_PROP_EXECUTABLE) == 0
|| strcmp(prop_name, SVN_PROP_NEEDS_LOCK) == 0
|| strcmp(prop_name, SVN_PROP_SPECIAL) == 0)
return TRUE;
return FALSE;
}
svn_boolean_t
svn_prop_needs_translation(const char *propname)
{
/* ### Someday, we may want to be picky and choosy about which
properties require UTF8 and EOL conversion. For now, all "svn:"
props need it. */
return svn_prop_is_svn_prop(propname);
}
svn_boolean_t
svn_prop_name_is_valid(const char *prop_name)
{
const char *p = prop_name;
/* The characters we allow use identical representations in UTF8
and ASCII, so we can just test for the appropriate ASCII codes.
But we can't use standard C character notation ('A', 'B', etc)
because there's no guarantee that this C environment is using
ASCII. */
if (!(svn_ctype_isalpha(*p)
|| *p == SVN_CTYPE_ASCII_COLON
|| *p == SVN_CTYPE_ASCII_UNDERSCORE))
return FALSE;
p++;
for (; *p; p++)
{
if (!(svn_ctype_isalnum(*p)
|| *p == SVN_CTYPE_ASCII_MINUS
|| *p == SVN_CTYPE_ASCII_DOT
|| *p == SVN_CTYPE_ASCII_COLON
|| *p == SVN_CTYPE_ASCII_UNDERSCORE))
return FALSE;
}
return TRUE;
}
|
83586f941ece664c3c3b36a10a91c112a5d4f114
|
254a54839186792de975dd0aa7a5300769652b7a
|
/src/stltwalker.c
|
c0f6320a3583c15bbcdb197684190e7e969a792d
|
[
"MIT"
] |
permissive
|
sshirokov/stltwalker
|
ae9fe8925eceea49262d2a2628dd72f8e9ef2881
|
dffe277b5ff133aeacacf77becf2a4f76d943db3
|
refs/heads/master
| 2020-06-02T16:09:44.675354 | 2014-02-05T19:05:19 | 2014-02-05T19:05:19 | 6,803,033 | 11 | 3 | null | 2014-02-05T19:05:20 | 2012-11-21T21:07:57 |
C
|
UTF-8
|
C
| false | false | 11,949 |
c
|
stltwalker.c
|
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "klist.h"
#include "dbg.h"
#include "stl.h"
#include "transform.h"
#include "pack.h"
const char *Version[] = {"0", "0", "3"};
struct Options {
enum {Collect, Pack, Copy} op;
// .op == Pack options
float padding;
float3 max_model_lwh;
// Disables centering the model before chaining other transforms
int raw_load;
int raw_out;
stl_transformer out;
int describe_level;
char *out_file;
// Verbosity level
int volume;
};
struct Options options = {
.op = Collect,
.padding = 5.0,
.max_model_lwh = FLOAT3_INIT_MAX,
.raw_load = 0,
.raw_out = 0,
.describe_level = 0,
.out_file = NULL,
.volume = 0
};
void usage(int argc, char **argv, char *err, ...) {
va_list va;
FILE *stream = stderr;
fprintf(stream, "%s [-options] {file0 [--operations]..}..{fileN [--operations]..}\n", argv[0]);
fprintf(stream, "\tv%s.%s.%s\n", Version[0], Version[1], Version[2]);
fprintf(stream, "\n");
fprintf(stream, "Options:\n");
fprintf(stream, "\t-h\tShow help\n");
fprintf(stream, "\t-I\tCopy maximum 1 input object to output memory directly.\n");
fprintf(stream, "\t-L <float>\tMaximum result object length\n");
fprintf(stream, "\t-W <float>\tMaximum result object width\n");
fprintf(stream, "\t-H <float>\tMaximum result object height\n");
fprintf(stream, "\t-p\tPack input objects automatically\n");
fprintf(stream, "\t-b <float>\tSet packing margin\n");
fprintf(stream, "\t-o filename\tOutput the resulting composite object to `filename'\n");
fprintf(stream, "\t-r\tDo not center and raise object above the Z plane on load\n");
fprintf(stream, "\t-R\tDo not center and raise the result object above the Z plane\n");
fprintf(stream, "\t-Z\tApply all pending transforms and place the current model on the Z plane\n");
fprintf(stream, "\t-D\tIncrease the detail with which the result is described\n");
fprintf(stream, "\n");
fprintf(stream, "Transforms:\n");
for(transformer *t = (transformer*)transformers; t->name != NULL; t++) {
fprintf(stream, "\t--%s=<options>\t%s\n", t->name, t->description);
}
fprintf(stream, "\n");
if(err) {
char *e_fmt = calloc(strlen("[PADDING]error: ") + strlen(err), sizeof(char));
check_mem(e_fmt);
sprintf(e_fmt, "ERROR: %s\n", err);
va_start(va, err);
vfprintf(stream, e_fmt, va);
free(e_fmt);
va_end(va);
}
exit(err ? 1 : 0);
error:
exit(-1);
}
int main(int argc, char *argv[]) {
if(argc < 2) usage(argc, argv, "Not enough arguments.");
int rc = -1;
klist_t(transformer) *in_objects = kl_init(transformer);
transformer_init(&options.out, NULL);
stl_transformer *latest = &options.out;
// Read options, load files, chain transforms
char opt;
int i = 1;
for(char *arg = argv[i]; i < argc; arg=argv[++i]) {
// Transforms
if(strncmp(arg, "--", 2) == 0) {
char t_name[256] = {0};
char t_args[256] = {0};
check(strlen(arg) < (sizeof(t_name) - 1) + (sizeof(t_args) - 1), "Transform declaration is too long: %zd", strlen(arg));
rc = sscanf(arg, "--%[^=]=%s", t_name, t_args);
check(rc >= 1, "Invalid transform spec '%s', format '--name=args'", arg);
float4x4 transform_mat;
transform_t transform = transform_find(t_name);
check(transform != NULL, "Unknown transform %s", t_name);
check(transform(&transform_mat, t_args) != NULL, "Failed to build transform %s(%s)", t_name, t_args);
transform_chain(latest, transform_mat);
}
// Options
else if(arg[0] == '-' && strlen(arg) == 2) {
switch((opt = arg[1])) {
case 'L': {
char *dim = argv[++i];
check(i < argc, "-%c requires a numeric parameter", opt);
check(sscanf(dim, "%f", &options.max_model_lwh[0]) == 1,
"Invalid maximum length '%s'", dim);
break;
}
case 'W': {
char *dim = argv[++i];
check(i < argc, "-%c requires a numeric parameter", opt);
check(sscanf(dim, "%f", &options.max_model_lwh[1]) == 1,
"Invalid maximum width '%s'", dim);
break;
}
case 'H': {
char *dim = argv[++i];
check(i < argc, "-%c requires a numeric parameter", opt);
check(sscanf(dim, "%f", &options.max_model_lwh[2]) == 1,
"Invalid maximum height '%s'", dim);
break;
}
case 'Z': {
log_info("Applying pending transforms for %c", opt);
transform_apply(latest);
log_info("Chaining and applying Z-plane transform");
object_transform_chain_zero_z(latest);
transform_apply(latest);
break;
}
case 'o':
latest = &options.out;
check(i + 1 < argc, "-%c requires a filename.", opt);
options.out_file = argv[++i];
break;
case 'b':
check(i + 1 < argc, "-%c requires a size.", opt);
rc = sscanf(argv[++i], "%f", &options.padding);
check(rc == 1, "-%c requires a size.", opt);
log_info("Padding is now %f", options.padding);
break;
case 'p':
log_info("Setting accumilation mode to Pack");
options.op = Pack;
break;
case 'I':
log_info("Setting memcopy collection mode.");
options.op = Copy;
break;
case 'r':
options.raw_load = !options.raw_load;
log_info("Raw load is now %s", options.raw_load ? "ON" : "OFF");
break;
case 'R':
options.raw_out = !options.raw_out;
options.out.options = Noop;
log_info("Raw out is now %s", options.raw_out ? "ON" : "OFF");
break;
case 'D':
log_info("Result description level is now %d", ++options.describe_level);
break;
case 'h':
usage(argc, argv, NULL);
default:
usage(argc, argv, "Unknown option %c", opt);
}
}
// Input loading
else {
latest = transformer_alloc(stl_read_file(arg));
check(latest != NULL, "Failed to create transformer");
check(latest->object != NULL, "Failed to load object from '%s'", arg);
if(!options.raw_load) {
log_info("Centering '%s'", arg);
// Center and +Z the object
object_transform_chain_zero_z(latest);
object_transform_chain_center_x(latest);
object_transform_chain_center_y(latest);
// Apply any potential chained object transforms
transform_apply(latest);
}
else {
latest->options = Noop;
log_info("NOT Centering '%s'", arg);
}
float3 b[2] = {FLOAT3_INIT, FLOAT3_INIT};
float3 c = FLOAT3_INIT_MAX;
object_bounds(latest->object, &b[0], &b[1]);
object_center(latest->object, &c);
log_info("%s center: (%f, %f, %f). Size: %fx%fx%f", arg, FLOAT3_FORMAT(c), f3X(b[1]) - f3X(b[0]), f3Y(b[1]) - f3Y(b[0]), f3Z(b[1]) - f3Z(b[0]));
*kl_pushp(transformer, in_objects) = latest;
log_info("Loaded: %s", arg);
}
}
// Transform each object and count the total
// facets for the output
kliter_t(transformer) *tl_iter = NULL;
uint32_t total_facets = 0;
rc = transform_apply_list(in_objects);
for(tl_iter = kl_begin(in_objects); tl_iter != kl_end(in_objects); tl_iter = kl_next(tl_iter)) {
total_facets += kl_val(tl_iter)->object->facet_count;
}
check(total_facets > 0, "%d facets in resulting model is insufficient.", total_facets);
// Compile and transform the output object
check_mem(options.out.object = stl_alloc(NULL, total_facets));
switch(options.op) {
case Collect: {
int collected = collect(options.out.object, in_objects);
check(collected == total_facets, "Facets lost during collection.");
break;
}
case Copy: {
check(in_objects->size == 1, "Identiy-copy accumilation only allows for one input.");
stl_object* input = kl_val(kl_begin(in_objects))->object;
memcpy(options.out.object->header, input->header, sizeof(input->header));
memcpy(options.out.object->facets, input->facets, sizeof(stl_facet) * input->facet_count);
break;
}
case Pack: {
check(chain_pack(in_objects, options.padding) == in_objects->size,
"Failed to chain pack transforms for all objects.");
check(transform_apply_list(in_objects) == in_objects->size,
"Failed to apply pack transforms for all objects.");
check(collect(options.out.object, in_objects) == total_facets,
"Facets lost during collection.");
break;
}
default:
sentinel("Unknown operation %d", options.op);
}
// Apply transformations to the result
log_info("Output contains %d facets, performing accumilated transforms", total_facets);
transform_apply(&options.out);
// Make sure the result object is centered if needed
log_info("%sCentering output object.", options.raw_out ? "NOT " : "");
if(!options.raw_out) {
object_transform_chain_zero_z(&options.out);
object_transform_chain_center_x(&options.out);
object_transform_chain_center_y(&options.out);
transform_apply(&options.out);
}
// Perform bounds checking
float3 bounds[2] = {FLOAT3_INIT, FLOAT3_INIT};
object_bounds(options.out.object, &bounds[0], &bounds[1]);
float3 dims = {f3X(bounds[1]) - f3X(bounds[0]), f3Y(bounds[1]) - f3Y(bounds[0]), f3Z(bounds[1]) - f3Z(bounds[0])};
check((dims[0] <= options.max_model_lwh[0]) &&
(dims[1] <= options.max_model_lwh[1]) &&
(dims[2] <= options.max_model_lwh[2]),
"Bounds check FAILED: Result dimensions: %f x %f x %f Maximum dimensions: %f x %f x %f",
FLOAT3_FORMAT(dims), FLOAT3_FORMAT(options.max_model_lwh));
// Perform the "result" operation
if(options.out_file != NULL) {
log_info("Writing result object to: '%s'", options.out_file);
rc = stl_write_file(options.out.object, options.out_file);
check(rc == 0, "Failed to write output to %s" , options.out_file);
}
// Describe the result in as much detail as requested.
if(options.describe_level > 0) {
float3 center = FLOAT3_INIT;
check(object_center(options.out.object, ¢er) == 0,
"Failed to get center of output object: %p", options.out.object);
printf("=> Output object description:\n");
printf("\tDimensions: %f x %f x %f Max: %f x %f x %f\n",
FLOAT3_FORMAT(dims), FLOAT3_FORMAT(options.max_model_lwh));
printf("\tCenter: (%f, %f, %f)\n", FLOAT3_FORMAT(center));
printf("\t%d faces\n", options.out.object->facet_count);
}
if(options.describe_level > 1) {
log_info("=> Header.");
for(int i = 0; i < sizeof(options.out.object->header); i += 16) {
log_info("[0x%02X] %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", i,
options.out.object->header[i+0],
options.out.object->header[i+1],
options.out.object->header[i+2],
options.out.object->header[i+3],
options.out.object->header[i+4],
options.out.object->header[i+5],
options.out.object->header[i+6],
options.out.object->header[i+7],
options.out.object->header[i+8],
options.out.object->header[i+9],
options.out.object->header[i+10],
options.out.object->header[i+11],
options.out.object->header[i+12],
options.out.object->header[i+13],
options.out.object->header[i+14],
options.out.object->header[i+15]
);
}
}
if(options.describe_level > 2) {
log_info("=> Faces:");
for(uint32_t i = 0; i < options.out.object->facet_count; i++) {
stl_facet* facet = &options.out.object->facets[i];
log_info("\t%d Attr: 0x%X: Normal: <%f, %f, %f>",
i, facet->attr, FLOAT3_FORMAT(facet->normal));
for(int v = 0; v < 3; v++) {
log_info("\t\t%d: (%f, %f, %f)",
v, FLOAT3_FORMAT(facet->vertices[v]));
}
}
}
kl_destroy(transformer, in_objects);
return 0;
error:
kl_destroy(transformer, in_objects);
return -1;
}
|
43eba85fd2d8107ba66ff11a3fb2b26b17044b7f
|
cc272ab919a5bc94a7bb39e61ff6585d269a0aeb
|
/firmware/cpu_ledcounter_app/src/main.c
|
2bd95be3d0b01aa01d62a14925a1f32d623ab277
|
[] |
no_license
|
chaoslion/basys2
|
3d75cf867364e2a6c93ac654eb043c1344ba0578
|
04d6b2371aaa50044e480450b27cdefa751dabcc
|
refs/heads/master
| 2022-09-19T17:06:46.914874 | 2016-10-18T08:53:28 | 2016-10-18T08:53:28 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,327 |
c
|
main.c
|
#include <stdio.h>
#include "xparameters.h"
#include "xil_cache.h"
#include "xiomodule.h"
#include "xil_exception.h"
XIOModule iomodule;
volatile u8 counter = 0;
void fit1_irq(void* ref) {
XIOModule_DiscreteWrite(&iomodule, 0x1, counter++);
}
void pit1_irq(void* ref) {
XIOModule_DiscreteWrite(&iomodule, 0x1, counter++);
}
int main() {
Xil_ICacheEnable();
Xil_DCacheEnable();
XIOModule_Initialize(&iomodule, XPAR_IOMODULE_0_DEVICE_ID);
XIOModule_Start(&iomodule);
XIOModule_Connect(&iomodule, XIN_IOMODULE_FIT_1_INTERRUPT_INTR, fit1_irq, NULL);
XIOModule_Enable(&iomodule, XIN_IOMODULE_FIT_1_INTERRUPT_INTR);
/*
XIOModule_Timer_Initialize(&iomodule, XPAR_IOMODULE_0_DEVICE_ID);
XIOModule_SetResetValue(&iomodule, 0, 390625*1);
XIOModule_Timer_SetOptions(&iomodule, 0, XTC_AUTO_RELOAD_OPTION);
XIOModule_Connect(&iomodule, XIN_IOMODULE_PIT_1_INTERRUPT_INTR, pit1_irq, NULL);
XIOModule_Enable(&iomodule, XIN_IOMODULE_PIT_1_INTERRUPT_INTR);
XIOModule_Timer_Start(&iomodule, 0);
*/
microblaze_enable_interrupts();
Xil_ExceptionInit();
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT, (Xil_ExceptionHandler) XIOModule_DeviceInterruptHandler, NULL);
Xil_ExceptionEnable();
// XIOModule_DiscreteWrite(&iomodule, 0x1, 0xFF);
while(1);
return 0;
}
|
5875a6df2db1ae739a85d9ab66973510781d6ecc
|
a45cb267223f6a99626f977cabb31866ee126a27
|
/jni/alidvb/hld_inc/alidrivers/include/mach-ali/sleepdep.h
|
fe448f1a22445907e7819843d623deb2c7c333a4
|
[] |
no_license
|
Hoelezh/TVActivity-dtmb
|
9d7208e7992daf4986ccd7b5c7caa274c53ec984
|
c11272f732ffd36d945d35365d4a697e025ede0c
|
HEAD
| 2016-09-05T12:39:45.718538 | 2015-03-07T01:10:23 | 2015-03-07T01:10:23 | 32,116,304 | 3 | 3 | null | null | null | null |
UTF-8
|
C
| false | false | 2,097 |
h
|
sleepdep.h
|
/*
* sleep dependnecy.h
* This file contains all the sleep hardware dependencies.
*
*/
#ifndef __ALI_M36_SLEEP_DEPENDENCY_INCLUDE____H__
#define __ALI_M36_SLEEP_DEPENDENCY_INCLUDE____H__
#include <linux/suspend.h>
#include <linux/delay.h>
#include <asm/io.h>
#define ALI_IRC_BASE 0x18018100 /* Memory base for ALI_M3602_IRC */
#define INFRA_IRCCFG (ALI_IRC_BASE + 0x00)
#define INFRA_FIFOCTRL (ALI_IRC_BASE + 0x01)
#define INFRA_TIMETHR (ALI_IRC_BASE + 0x02)
#define INFRA_NOISETHR (ALI_IRC_BASE + 0x03)
#define INFRA_IER (ALI_IRC_BASE + 0x06)
#define INFRA_ISR (ALI_IRC_BASE + 0x07)
#define INFRA_RLCBYTE (ALI_IRC_BASE + 0x08)
#define INTV_REPEAT 250 /* in mini second */
#define INTV_REPEAT_FIRST 300 /* in mini second */
#define PAN_KEY_INVALID 0xFFFFFFFF
#define VALUE_TOUT 24000 /* Timeout threshold, in uS */
#define VALUE_CLK_CYC 8 /* Work clock cycle, in uS */
#define VALUE_NOISETHR 80 /* Noise threshold, in uS */
#define IR_RLC_SIZE 256
#define IO_BASE_ADDR 0x18000000
#define AUDIO_IO_BASE_ADDR 0x18002000
#define USB_IO_BASE_ADDR 0x1803d800
#define HDMI_PHY 0x1800006c
#define SYS_IC_NB_BASE_H 0x1800
#define SYS_IC_NB_CFG_SEQ0 0x74
#define SYS_IC_NB_BIT1033 0x1033
#define SYS_IC_NB_BIT1031 0x1031
/*
* Useful MACROs
*/
#define SYNC() \
do { \
asm volatile ("sync; ehb"); \
} while (0)
#define SDBBP() \
do { \
asm volatile (".word 0x7000003f; nop"); \
} while (0)
static inline void suspend_step(char c)
{/*
//#define PM_SUSPEND_STEP_DBG
#ifdef PM_SUSPEND_STEP_DBG
unsigned char *d_t = (unsigned char *)0xb8018300;
int i = 10000;
*d_t = c;
while (i-- > 0) ;
i = 10000;
*d_t = c;
while (i-- > 0) ;
#endif*/
}
#define PM_ENABLE_DEVICE 1
#define PM_DISABLE_DEVICE 0
#define PM_ENTER_STANDBY 1
#define PM_EXIT_STANDBY 0
void operate_device(int enable);
void pm_standby_prepare(int enter);
void operate_time_count(unsigned long timeout);
#endif
|
c1f0bd2879a6e8c5f9550cb45b47a23b3dbce8a4
|
d1323d3e28414b3208a769d34a63d8b056085ead
|
/Lab1_UnixTerminal/main.c
|
863dbef69ffcc2ddc023af516c73dfc33b85cccf
|
[] |
no_license
|
sagrawal8/C-Projects
|
7d95d73991f30283c7a56c1da97c926715c6ca33
|
3fef64b0d81f7776878e0ef8efb5f84ff27b3ef2
|
refs/heads/main
| 2023-04-14T20:34:44.704686 | 2021-04-22T22:06:45 | 2021-04-22T22:06:45 | 362,933,371 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 516 |
c
|
main.c
|
#include <stdio.h>
double power(double base, double n){
int i;
int product = base;
for (i = 0; i < n; i++){
product *= base;
}
return product;
}
int main(){
int i;
char* str = "";
for(i = 0; i < 10; i++){
if(i == 0){
str = "st";
}
else if(i == 1){
str = "nd";
}
else if(i == 2){
str = "rd";
}
else{
str = "th";
}
printf("2 to the %d%s power is: %f\n", i+1, str, power(2, i));
}
}
|
a40ef82fb4193c0afe1d842a95b9a2988d858f96
|
e83936e63bfa3c2b6b2a302ad8e10f9e2b7decb6
|
/Lista18/Exercicio04-Lista18.c
|
5421cb7858a4eff50a2fb82021fb9f9b3a267ab6
|
[] |
no_license
|
rafaelschettino/Algoritmos-e-Estruturas-de-Dados-I
|
0493fc0226ebfd3eec4a99d52455919ec0cab042
|
fc6463696e611c6006529b3c5ac5f60e6f3531e2
|
refs/heads/master
| 2022-12-08T11:39:24.559123 | 2020-08-27T14:52:13 | 2020-08-27T14:52:13 | 285,069,145 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,243 |
c
|
Exercicio04-Lista18.c
|
#include <stdio.h>
#include <stdlib.h>
const int num_lin = 3;
const int num_col = 3;
void leMatriz(float matriz[][num_col]);
float maiorAcimaDiagonal(float matriz[][num_col]);
void escreveResultado(float maior_valor);
int main()
{
float matriz[num_lin][num_col];
leMatriz(matriz);
float maior_valor = maiorAcimaDiagonal(matriz);
escreveResultado(maior_valor);
}//fim main()
void leMatriz(float matriz[][num_col])
{
for(int i = 0; i < num_lin; i++){
for(int j = 0; j < num_col; j++){
printf("\nM[%d][%d]: ",i + 1, j + 1);
scanf("%f", &matriz[i][j]);
}//fim for j
}//fim for i
}//fim leMatriz()
float maiorAcimaDiagonal(float matriz[][num_col])
{
int i = 0;
int j = 0;
float maior = matriz[i][j];
while(j < num_col){
i++;
if(i == j){
i = 0;
j++;
}//fim if
if(i < j){
if(matriz[i][j] > maior) maior = matriz[i][j];
}//fim if
}//fim while
return maior;
}//fim maiorAcimaDiagonal()
void escreveResultado(float maior_valor)
{
printf("\nO maior valor acima da diagonal principal = %f", maior_valor);
}//fim escreveResultado()
|
22a2e07abeb450b96ec157abd2dc22ff31a9e6b6
|
8d753bb8f19b5b1f526b0688d3cb199b396ed843
|
/osp_sai_2.1.8/system/fea/lcm/lcmmsg/gen/LcFiberModuleUpdateMsg.c
|
0b48ad0bb8b8dda23ef4ceb43f9187b5bb5f8f8e
|
[] |
no_license
|
bonald/vim_cfg
|
f166e5ff650db9fa40b564d05dc5103552184db8
|
2fee6115caec25fd040188dda0cb922bfca1a55f
|
refs/heads/master
| 2023-01-23T05:33:00.416311 | 2020-11-19T02:09:18 | 2020-11-19T02:09:18 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 4,920 |
c
|
LcFiberModuleUpdateMsg.c
|
/*
* Generated by asn1c-0.9.20 (http://lionet.info/asn1c)
* From ASN.1 module "LCM"
* found in "../lcm.asn1"
*/
#include <asn_internal.h>
#include "LcFiberModuleUpdateMsg.h"
static asn_TYPE_member_t asn_MBR_LcFiberModuleUpdateMsg_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, slot),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_NativeInteger,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"slot"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, port),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_NativeInteger,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"port"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, ddm),
(ASN_TAG_CLASS_CONTEXT | (2 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_NativeInteger,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"ddm"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, txPwr),
(ASN_TAG_CLASS_CONTEXT | (3 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_FiberModuleValues,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"txPwr"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, rxPwr),
(ASN_TAG_CLASS_CONTEXT | (4 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_FiberModuleValues,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"rxPwr"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, bias),
(ASN_TAG_CLASS_CONTEXT | (5 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_FiberModuleValues,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"bias"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, tmpr),
(ASN_TAG_CLASS_CONTEXT | (6 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_FiberModuleValues,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"tmpr"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, vcc),
(ASN_TAG_CLASS_CONTEXT | (7 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_FiberModuleValues,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"vcc"
},
{ ATF_NOFLAGS, 0, offsetof(struct LcFiberModuleUpdateMsg, tunableinfo),
(ASN_TAG_CLASS_CONTEXT | (8 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_TunableValues,
0, /* Defer constraints checking to the member type */
0, /* PER is not compiled, use -gen-PER */
0,
"tunableinfo"
},
};
static ber_tlv_tag_t asn_DEF_LcFiberModuleUpdateMsg_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_LcFiberModuleUpdateMsg_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* slot at 550 */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* port at 551 */
{ (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* ddm at 552 */
{ (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 }, /* txPwr at 553 */
{ (ASN_TAG_CLASS_CONTEXT | (4 << 2)), 4, 0, 0 }, /* rxPwr at 554 */
{ (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 5, 0, 0 }, /* bias at 555 */
{ (ASN_TAG_CLASS_CONTEXT | (6 << 2)), 6, 0, 0 }, /* tmpr at 556 */
{ (ASN_TAG_CLASS_CONTEXT | (7 << 2)), 7, 0, 0 }, /* vcc at 557 */
{ (ASN_TAG_CLASS_CONTEXT | (8 << 2)), 8, 0, 0 } /* tunableinfo at 559 */
};
static asn_SEQUENCE_specifics_t asn_SPC_LcFiberModuleUpdateMsg_specs_1 = {
sizeof(struct LcFiberModuleUpdateMsg),
offsetof(struct LcFiberModuleUpdateMsg, _asn_ctx),
asn_MAP_LcFiberModuleUpdateMsg_tag2el_1,
9, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_LcFiberModuleUpdateMsg = {
"LcFiberModuleUpdateMsg",
"LcFiberModuleUpdateMsg",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
0, /* No PER decoder, -gen-PER to enable */
0, /* Use generic outmost tag fetcher */
asn_DEF_LcFiberModuleUpdateMsg_tags_1,
sizeof(asn_DEF_LcFiberModuleUpdateMsg_tags_1)
/sizeof(asn_DEF_LcFiberModuleUpdateMsg_tags_1[0]), /* 1 */
asn_DEF_LcFiberModuleUpdateMsg_tags_1, /* Same as above */
sizeof(asn_DEF_LcFiberModuleUpdateMsg_tags_1)
/sizeof(asn_DEF_LcFiberModuleUpdateMsg_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_LcFiberModuleUpdateMsg_1,
9, /* Elements count */
&asn_SPC_LcFiberModuleUpdateMsg_specs_1 /* Additional specs */
};
|
0b49da304e00c4ae56613956c057d1bcfc2faf4a
|
dd673f95140e08224e056b3282eb6de1e9818dde
|
/week6/stack/stack.c
|
2082c50b603e5103db9123eb4bbb3c36d0a072af
|
[] |
no_license
|
hdhwq/LED2
|
25cd33411cbfded78880c50de3caa8bd32616d44
|
05d2471cb4ac8169f4aaed5901538ee3b4aa1082
|
refs/heads/master
| 2020-05-25T15:22:58.550542 | 2017-04-21T14:39:06 | 2017-04-21T14:39:06 | 84,943,633 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 765 |
c
|
stack.c
|
#include "stack.h"
stack_t *stack_init()
{
stack_t *stack= (stack_t *)malloc(sizeof(stack_t));
return stack;
}
void enqueue(queue_t *queue, int value)
{
if(queue==NULL)
return;
node_t *newnode = (node_t *)malloc(sizeof (node_t));
newnode->data = value;
newnode->next =NULL;
if(queue->front==NULL && queue->rear==NULL)
{
queue->front = newnode;
queue->rear = newnode;
}
else
{
queue->rear->next = newnode;
queue->rear =newnode;
}
}
int dequeue(queue_t *queue)
{
if(queue==NULL)
return -999;
if(queue->front==NULL && queue->rear==NULL)
return -999;
node_t *tmp;
tmp = queue->front;
queue->front = queue->front->next;
if(queue->front == NULL)
queue->rear =NULL;
int v = tmp->data;
free(tmp);
return v;
}
|
4db6aa598281e8faddd95c9762e97f16c8c0539b
|
4eb9507401186dd2d2377701f45bed0c5e6cc5e7
|
/JavaToCSharpConverter/Source/CandC++/org_Rescue_rjni_RescuePillar.h
|
266229f7272d78b573958c1d277fc1816b9a263a
|
[] |
no_license
|
SkivHisink/Java-To-CSharp-Converter-v0.1
|
9a234f0217cd19643892f7da5a7ecefd458b4565
|
fbc05608860e76b0462298ae8b78eec066f30353
|
refs/heads/master
| 2022-11-23T23:22:24.395922 | 2020-07-27T11:53:40 | 2020-07-27T11:53:40 | 282,883,085 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | true | 6,240 |
h
|
org_Rescue_rjni_RescuePillar.h
|
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_Rescue_rjni_RescuePillar */
#ifndef _Included_org_Rescue_rjni_RescuePillar
#define _Included_org_Rescue_rjni_RescuePillar
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: Create_RescuePillar0
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_Create_1RescuePillar0
(JNIEnv *, jobject);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: Delete_RescuePillar
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_Delete_1RescuePillar
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: VertexIs2
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_Rescue_rjni_RescuePillar_VertexIs2
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: NodeValues7
* Signature: (JJJJ)[F
*/
JNIEXPORT jfloatArray JNICALL Java_org_Rescue_rjni_RescuePillar_NodeValues7
(JNIEnv *, jobject, jlong, jlong, jlong, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: NodeValuesLength8
* Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_org_Rescue_rjni_RescuePillar_NodeValuesLength8
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: KValue9
* Signature: (JJ)F
*/
JNIEXPORT jfloat JNICALL Java_org_Rescue_rjni_RescuePillar_KValue9
(JNIEnv *, jobject, jlong, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: KValueR9
* Signature: (JJJ)F
*/
JNIEXPORT jfloat JNICALL Java_org_Rescue_rjni_RescuePillar_KValueR9
(JNIEnv *, jobject, jlong, jlong, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: ZValue10
* Signature: (JJF)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_ZValue10
(JNIEnv *, jobject, jlong, jlong, jfloat);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: ZStack11
* Signature: (JJ[F)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_ZStack11
(JNIEnv *, jobject, jlong, jlong, jfloatArray);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: ZStack12
* Signature: (JJJ[F)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_ZStack12
(JNIEnv *, jobject, jlong, jlong, jlong, jfloatArray);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: IsSplit13
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_Rescue_rjni_RescuePillar_IsSplit13
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: IsVertical14
* Signature: (J)Z
*/
JNIEXPORT jboolean JNICALL Java_org_Rescue_rjni_RescuePillar_IsVertical14
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: TopTruncation15
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_TopTruncation15
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: BaseTruncation16
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_BaseTruncation16
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: SetTopTruncation17
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_SetTopTruncation17
(JNIEnv *, jobject, jlong, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: SetBaseTruncation18
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_SetBaseTruncation18
(JNIEnv *, jobject, jlong, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: AddControlPoint19
* Signature: (JFFF)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_AddControlPoint19
(JNIEnv *, jobject, jlong, jfloat, jfloat, jfloat);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: rebuildSplineCoeffs20
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_rebuildSplineCoeffs20
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: AddControlPoint21
* Signature: (JFFFFFFFFF)V
*/
JNIEXPORT void JNICALL Java_org_Rescue_rjni_RescuePillar_AddControlPoint21
(JNIEnv *, jobject, jlong, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getByZ22
* Signature: (JF)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getByZ22
(JNIEnv *, jobject, jlong, jfloat);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getMinTangent23
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getMinTangent23
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getMaxTangent24
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getMaxTangent24
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getNumCtrlPoints25
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getNumCtrlPoints25
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getMinCtrlPoint26
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getMinCtrlPoint26
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getMaxCtrlPoint27
* Signature: (J)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getMaxCtrlPoint27
(JNIEnv *, jobject, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getCtrlPointAt28
* Signature: (JJ)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getCtrlPointAt28
(JNIEnv *, jobject, jlong, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getXSplineCoefAt29
* Signature: (JJ)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getXSplineCoefAt29
(JNIEnv *, jobject, jlong, jlong);
/*
* Class: org_Rescue_rjni_RescuePillar
* Method: getYSplineCoefAt30
* Signature: (JJ)J
*/
JNIEXPORT jlong JNICALL Java_org_Rescue_rjni_RescuePillar_getYSplineCoefAt30
(JNIEnv *, jobject, jlong, jlong);
#ifdef __cplusplus
}
#endif
#endif
|
d726a4deb390d4348995453a7c9e80437397f486
|
24aa29f56330f1bb424afe48b632e89dc66e4d08
|
/srcs/trap/trap/trap_signal_handler.c
|
d49c051a0755a441435dbde5635675434f8dd58f
|
[] |
no_license
|
AlexandreYang/42sh_posix
|
b01b147c7ffde7d89fd736967866d4b04871abed
|
c7aa1322ad67b76a621f41523666d0d55a957198
|
refs/heads/master
| 2020-06-28T22:40:35.225078 | 2017-10-26T17:55:45 | 2017-10-26T17:55:45 | 200,360,559 | 1 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,668 |
c
|
trap_signal_handler.c
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* check_norris_loves_the_norminette.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: chuck <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2042/02/30 42:00:00 by chuck #+# #+# */
/* Updated: 2042/02/30 41:59:59 by chuck ### ########.fr */
/* */
/* ************************************************************************** */
#include "trap/trap_mgr.h"
#include "twl_logger.h"
#include "shenv/shenv.h"
#include "data.h"
#include "shsignal/shsignal_mgr.h"
#include "builtin/cmds/builtin_eval.h"
static void trap_signal_handler_exec(t_trap *trap)
{
int saved_exit_status;
saved_exit_status = shenv_singleton()->last_exit_code;
builtin_eval_exec_str(trap->trap_action);
shenv_singleton()->last_exit_code = saved_exit_status;
}
void trap_signal_handler(int signum)
{
t_trap *trap;
LOG_INFO("trap_signal_handler called with: %s(%d)",
shsignal_mgr_get_signame(data_signals(), signum), signum);
trap = trap_mgr_find_by_signum(shenv_singleton()->shenv_traps, signum);
if (trap)
{
trap_signal_handler_exec(trap);
}
else
{
LOG_ERROR("Trap not found for signum: %d", signum);
}
}
|
33c00f4ed186e0f5f427066396eee025f8a340fa
|
89769ed671e8f4a195279e2e7e459abd68d81389
|
/bootstrap/states/verbatim.c
|
d8e77d754367a8d9059295952eb118d6ff43e74b
|
[] |
no_license
|
sbohmann/mini
|
030d9739a4eeaa7d68fa9956d13ce72adfdba19f
|
1e4b6e0d115a0b771e731056a6de011203142933
|
refs/heads/master
| 2023-09-01T11:09:18.165106 | 2023-08-28T16:59:54 | 2023-08-28T16:59:54 | 219,122,916 | 3 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 241 |
c
|
verbatim.c
|
#include <stdio.h>
#include "core.h"
void enter_verbatim_state() {
state = Verbatim;
}
void verbatim_process(char c) {
if (c == start_signature[0]) {
enter_start_signature_state();
} else {
putchar(c);
}
}
|
4b769119d79f6c8410b471a97be48a60522c6cc3
|
2875e427d9931ab8cfe2e066e1568c3130fcc3f2
|
/Solaris_2.6/os_net/src_ws/usr/src/cmd/fs.d/cachefs/fsck/dlog_ck.c
|
70cf3acbd203b18229c8692a3d00fc72249c2166
|
[] |
no_license
|
legacy-codedigger/Solaris-2.6-Source-Code
|
3afaff70487fb96c864d55bd5845dd11c6c5c871
|
60a0b3093caa7d84e63dd891a23df0e8e720bf3d
|
refs/heads/master
| 2022-05-23T16:05:32.631954 | 2020-04-25T01:07:08 | 2020-04-25T01:07:08 | 258,658,903 | 1 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 5,782 |
c
|
dlog_ck.c
|
/*
* Copyright (c) 1996, by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "@(#)dlog_ck.c 1.8 96/04/18 SMI"
#include <sys/types.h>
#include <stdio.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/fs/cachefs_fs.h>
#include <sys/fs/cachefs_dlog.h>
/* forward references */
static int create_mapfile(char *fname, int size);
int
dlog_ck(char *dir_path, ino64_t *maxlocalfilenop)
{
int err;
int n;
char dlog_path[MAXPATHLEN];
char dmap_path[MAXPATHLEN];
struct stat64 statinfo;
int fd;
int dlog_version;
off_t offset;
struct cfs_dlog_entry buf;
int max_seq_num;
int ent_count = 0;
ino64_t fileno, maxlocalfileno;
if (maxlocalfilenop)
*maxlocalfilenop = 0LL;
n = strlen(dir_path) + strlen(CACHEFS_DLOG_FILE) + 2;
if (n > MAXPATHLEN) {
pr_err(gettext("%s/%s: path too long"),
dir_path, CACHEFS_DLOG_FILE);
return (-1);
}
sprintf(dlog_path, "%s/%s", dir_path, CACHEFS_DLOG_FILE);
n = strlen(dir_path) + strlen(CACHEFS_DMAP_FILE) + 2;
if (n > MAXPATHLEN) {
pr_err(gettext("%s/%s: path too long"),
dir_path, CACHEFS_DMAP_FILE);
return (-1);
}
sprintf(dmap_path, "%s/%s", dir_path, CACHEFS_DMAP_FILE);
err = lstat64(dlog_path, &statinfo);
if (err < 0) {
if (errno == ENOENT)
(void) unlink(dmap_path);
/*
* No disconnect log(dlog) file exists to check
*/
return (0);
}
/* this file will be <2GB */
fd = open(dlog_path, O_RDWR);
if (fd < 0) {
pr_err(gettext("can't open %s"), dlog_path);
return (-2);
}
err = read(fd, &dlog_version, sizeof (dlog_version));
if (err != sizeof (dlog_version)) {
pr_err(gettext("can't read %s"), dlog_path);
(void) close(fd);
return (-3);
}
if (dlog_version != CFS_DLOG_VERSION) {
pr_err(gettext(
"unknown version number in %s"), dlog_path);
(void) close(fd);
return (-4);
}
offset = sizeof (dlog_version);
max_seq_num = 0;
maxlocalfileno = 0LL;
while (offset < (off_t)statinfo.st_size) {
err = (int) lseek(fd, offset, SEEK_SET);
if (err == -1) {
pr_err(gettext("can't lseek %s"), dlog_path);
(void) close(fd);
return (-5);
}
err = read(fd, &buf, sizeof (buf));
if (err < 0) {
pr_err(gettext("can't read %s"), dlog_path);
(void) close(fd);
return (-6);
}
++ent_count;
if (buf.dl_op == CFS_DLOG_TRAILER) {
goto out;
}
if ((buf.dl_len & 3) == 0) {
/*
* Record length must be on a word boundary and
* fit into the correct size range.
*/
if ((buf.dl_len < sizeof (int)) ||
(buf.dl_len > CFS_DLOG_ENTRY_MAXSIZE)) {
goto out;
}
/*
* Make sure length does not point beyond end of
* file
*/
if ((offset + (off_t)buf.dl_len) >
(off_t)statinfo.st_size) {
goto out;
}
} else {
goto out;
}
/* make sure the valid field is reasonable */
switch (buf.dl_valid) {
case CFS_DLOG_VAL_CRASH:
case CFS_DLOG_VAL_COMMITTED:
case CFS_DLOG_VAL_ERROR:
case CFS_DLOG_VAL_PROCESSED:
break;
default:
goto out;
}
/* make sure the operation field is reasonable */
fileno = 0LL;
switch (buf.dl_op) {
case CFS_DLOG_CREATE:
fileno = buf.dl_u.dl_create.dl_new_cid.cid_fileno;
break;
case CFS_DLOG_REMOVE:
break;
case CFS_DLOG_LINK:
break;
case CFS_DLOG_RENAME:
break;
case CFS_DLOG_MKDIR:
fileno = buf.dl_u.dl_mkdir.dl_child_cid.cid_fileno;
break;
case CFS_DLOG_RMDIR:
break;
case CFS_DLOG_SYMLINK:
fileno = buf.dl_u.dl_symlink.dl_child_cid.cid_fileno;
break;
case CFS_DLOG_SETATTR:
break;
case CFS_DLOG_SETSECATTR:
break;
case CFS_DLOG_MODIFIED:
break;
case CFS_DLOG_MAPFID:
break;
default:
goto out;
}
/* track the largest local fileno used */
if (maxlocalfileno < fileno)
maxlocalfileno = fileno;
/* track the largest sequence number used */
if (max_seq_num < buf.dl_seq) {
max_seq_num = buf.dl_seq;
}
offset += buf.dl_len;
}
out:
if ((buf.dl_op != CFS_DLOG_TRAILER) ||
(buf.dl_len != sizeof (struct cfs_dlog_trailer)) ||
(buf.dl_valid != CFS_DLOG_VAL_COMMITTED) ||
((offset + (off_t)buf.dl_len) != (off_t)statinfo.st_size)) {
ftruncate(fd, offset);
buf.dl_len = sizeof (struct cfs_dlog_trailer);
buf.dl_op = CFS_DLOG_TRAILER;
buf.dl_valid = CFS_DLOG_VAL_COMMITTED;
buf.dl_seq = max_seq_num + 1;
if (wrdlog(fd, &buf, buf.dl_len, offset) != 0) {
(void) close(fd);
return (-7);
}
}
if (fsync(fd) == -1) {
pr_err(gettext("Cannot sync %s"), dlog_path);
(void) close(fd);
return (-8);
}
(void) close(fd); /* ignore return since fsync() successful */
/* check to see that mapfile exists; if not, create it. */
if (access(dmap_path, F_OK) != 0) {
/* XXX ent_count is a very high upper bound */
if (create_mapfile(dmap_path,
ent_count * sizeof (struct cfs_dlog_mapping_space)) != 0) {
return (-9);
}
}
if (maxlocalfilenop)
*maxlocalfilenop = maxlocalfileno;
return (0);
}
int
wrdlog(int fd, char * buf, int len, off_t offset)
{
int err;
err = lseek(fd, offset, SEEK_SET);
if (err < 0) {
return (-1);
}
err = write(fd, buf, len);
if (err != len) {
return (-2);
}
return (0);
}
static int
create_mapfile(char *fname, int size)
{
char buffy[BUFSIZ];
int fd, rc, wsize;
/* this file will be <2GB */
fd = open(fname, O_WRONLY | O_CREAT | O_EXCL);
if (fd < 0)
return (errno);
memset(buffy, '\0', sizeof (buffy));
while (size > 0) {
wsize = (size > sizeof (buffy)) ? sizeof (buffy) : size;
if (write(fd, buffy, wsize) != wsize) {
rc = errno;
(void) close(fd);
(void) unlink(fname);
return (rc);
}
size -= wsize;
}
if (fsync(fd) != 0) {
rc = errno;
(void) close(fd);
(void) unlink(fname);
return (rc);
}
(void) close(fd);
return (0);
}
|
e72a38bdb81aef78187f9aed6ff920e56e5790f3
|
64f63e6468d7d1a8239ca8a60cb3a57671d7026e
|
/src/modulemgr/chunk.c
|
0214c5133727342bc9a91b6cb30ba66d2a9410a9
|
[
"BSD-3-Clause",
"MIT"
] |
permissive
|
uofw/uofw
|
511c6877af464a4c18cd62405805ed92b15b39c3
|
c517e4cee6679cf2c0ecb24afaa50a86c6460cf1
|
refs/heads/master
| 2023-02-09T17:10:03.719610 | 2023-02-03T13:11:50 | 2023-02-03T13:11:50 | 6,622,246 | 312 | 93 |
NOASSERTION
| 2023-09-05T19:54:15 | 2012-11-09T23:39:19 |
C
|
UTF-8
|
C
| false | false | 1,220 |
c
|
chunk.c
|
/* Copyright (C) 2011 - 2015 The uOFW team
See the file COPYING for copying permission.
*/
#include <common_imp.h>
/* The total number of available chunks. */
#define SCE_KERNEL_NUM_CHUNKS (16)
/* The slot of the highest available chunk. */
#define SCE_KERNEL_MAX_CHUNK (SCE_KERNEL_NUM_CHUNKS - 1)
/* The group of chunks to be used by the system. */
SceUID chunks[SCE_KERNEL_NUM_CHUNKS]; //0x00009A48
// sub_000086C0
void ChunkInit(void)
{
u32 i;
for (i = 0; i < SCE_KERNEL_NUM_CHUNKS; i++)
chunks[i] = SCE_KERNEL_VALUE_UNITIALIZED;
}
SceUID sceKernelGetChunk(s32 chunkId)
{
if (chunkId < 0 || chunkId > SCE_KERNEL_MAX_CHUNK)
return SCE_ERROR_KERNEL_ILLEGAL_CHUNK_ID;
return chunks[chunkId];
}
SceUID sceKernelRegisterChunk(s32 chunkId, SceUID blockId)
{
if (chunkId < 0 || chunkId > SCE_KERNEL_MAX_CHUNK)
return SCE_ERROR_KERNEL_ILLEGAL_CHUNK_ID;
chunks[chunkId] = blockId;
return blockId;
}
s32 sceKernelReleaseChunk(s32 chunkId)
{
if (chunkId < 0 || chunkId > SCE_KERNEL_MAX_CHUNK)
return SCE_ERROR_KERNEL_ILLEGAL_CHUNK_ID;
chunks[chunkId] = SCE_KERNEL_VALUE_UNITIALIZED;
return SCE_KERNEL_VALUE_UNITIALIZED;
}
|
fc96602da17cb1e8619904e60f261c853a823647
|
5f236bde955f38a801f2300a8d531dbbe137efa6
|
/keyboard.c
|
9f6cb099aee0ae7cf1481b145469022c5760a48e
|
[] |
no_license
|
ivadasz/libinput
|
ba7f9d7f02053ea3721cd650f88afeb7c46af3d9
|
a13c5ba9abb2fa06136e8df1e3b4e557394bba9e
|
refs/heads/master
| 2021-01-18T06:53:40.580025 | 2016-07-12T11:03:12 | 2016-07-12T11:03:12 | 62,505,495 | 0 | 0 | null | 2016-07-03T16:31:32 | 2016-07-03T16:31:30 |
C
|
UTF-8
|
C
| false | false | 1,885 |
c
|
keyboard.c
|
/*
* Copyright © 2015 Martin Pieuchot <[email protected]>
*
* 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 (including the next
* paragraph) 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 <assert.h>
#include <fcntl.h>
#include <stdarg.h>
#include <string.h>
#include <sys/mouse.h>
#include "kbdev.h"
#include "libinput.h"
#include "libinput-util.h"
#include "libinput-private.h"
void
keyboard_device_dispatch(void *data)
{
struct libinput_device *device = data;
struct kbdev_event evs[64];
struct timespec ts;
uint64_t time;
int i, n;
n = kbdev_read_events(device->kbdst, evs, 64);
if (n <= 0)
return;
clock_gettime(CLOCK_MONOTONIC, &ts);
time = ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
for (i = 0; i < n; i++) {
keyboard_notify_key(device, time, evs[i].keycode,
evs[i].pressed ? LIBINPUT_KEY_STATE_PRESSED
: LIBINPUT_KEY_STATE_RELEASED);
}
}
|
6058ef0cb05a14dba72dada8ff5152301655c74b
|
978e017b61919b617348c794f1af32930fddf46e
|
/ntrig/src/user/ntg_user.h
|
904e8f596ae4fcc998da44a99417ba16bcd21436
|
[] |
no_license
|
huxi-github/NTG_V2
|
7661692e94409d434d10627d8e1550f47591c790
|
b77d1e43a9b4e1d48fff4c3add6393ab282ad008
|
refs/heads/master
| 2020-03-30T04:40:46.127044 | 2018-10-02T14:30:56 | 2018-10-02T14:30:56 | 150,756,125 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 2,718 |
h
|
ntg_user.h
|
/**
* @file ntg_user.h
* @brief
* @details
* @author tzh
* @date Nov 20, 2015
* @version V0.1
* @copyright tzh
*/
#ifndef USER_NTG_USER_H_
#define USER_NTG_USER_H_
#include "../ntg_config.h"
#include "../ntg_core.h"
#include "../http/ntg_http.h"
#include "../utils/ntg_table.h"
#include "../utils/ntg_math.h"
#include "ntg_user_manage.h"
#include "ntg_user_consumer.h"
#include "ntg_user_group.h"
/* 用户模块魔术 */
#define NTG_USER_MODULE 0x52455355
#define NTG_USER_CONF 0x02000000
/**
* @name 用户对象
*/
struct ntg_user_s {
void *data;
ntg_uint_t user_id;///用户id
ntg_user_group_t *group;
struct event *event;///用户定时事件对象
struct timeval time;///超时时间
ntg_queue_t qele;///队列元素
ntg_log_t *log;///日志对象
// ntg_pool_t *pool;///用户内部内存池
/* 模型参数 */
ntg_uint_t clicks;///点击数
ntg_uint_t sessions;///会话数
ntg_int_t request_n;///允许的最大请求数
ntg_int_t have_rqs;///已有的reqest
unsigned live:1;///活跃标记
unsigned enable:1;///event已初始化
};
/**
* 用户行为函数
*/
typedef struct {
ntg_int_t (*get_time)(ntg_user_t *user, void *args);
ntg_int_t (*get_url)(ntg_user_t *user, void *args);
ntg_int_t (*init)(ntg_cycle_t *cycle, void *args);
ntg_int_t (*done)(ntg_cycle_t *cycle);
} ntg_user_actions_t;
/**
* @name 用户模块配置对象
*/
typedef struct {
ntg_uint_t worker_users;/// 每个工作进程中最多模拟的用户数
ntg_uint_t use;/// 选用的用户行为模块所在的序列号
ntg_uint_t req_num;/// 每个用户最多产生的请求数
ntg_uint_t blc_type;
u_char *name;/// 底层模块名称
} ntg_user_conf_t;
/**
* @name 用户模块定义
*/
typedef struct {
ntg_str_t *name;///模块名称
// 在解析配置项前,这个回调方法用于创建存储配置项参数的结构体
void *(*create_conf)(ntg_cycle_t *cycle);
// 在解析配置项完成后,init_conf方法会被调用,用于综合处理当前事件模块感兴趣的全部配置项。
char *(*init_conf)(ntg_cycle_t *cycle, void *conf);
ntg_user_actions_t actions;
} ntg_user_module_t;
extern ntg_module_t ntg_users_module;
extern ntg_module_t ntg_user_core_modules;
#define ntg_user_get_conf(conf_ctx, module) \
(*(ntg_get_conf(conf_ctx, ntg_users_module))) [module.ctx_index];
ntg_user_t * ntg_get_user(ntg_cycle_t *cycle, ntg_log_t *log);
void ntg_user_timeout_cb(evutil_socket_t fd, short what, void *arg);
//void ntg_user_timeout_handler(ntg_event_t *ev);
#endif /* USER_NTG_USER_H_ */
|
64c3a35086fdb1393bff2f6000afdf30467e414e
|
006ab26fa28c1332a21d188b20a110464f80b677
|
/dsmexec.c
|
3b10a893bcce2a9b1fdc47d02806fdc2f4155a3a
|
[] |
no_license
|
spauvert/ProgSyst
|
013a4c37f20e4aef2cb0b7568ac515e4d08e2a86
|
ecfcb507345d81bf74a40100cf56973a9f698116
|
refs/heads/master
| 2021-08-24T00:59:03.097969 | 2017-12-07T10:29:28 | 2017-12-07T10:29:28 | 110,946,526 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 8,421 |
c
|
dsmexec.c
|
#include "common_impl.h"
/* variables globales */
/* un tableau gerant les infos d'identification */
/* des processus dsm */
// dsm_proc_t *proc_array = NULL;
/* le nombre de processus effectivement crees */
volatile int num_procs_creat = 0;
//typedef char nom_machines_t[20];
void usage(void)
{
fprintf(stdout,"Usage : dsmexec machine_file executable arg1 arg2 ...\n");
fflush(stdout);
exit(EXIT_FAILURE);
}
void sigchld_handler( int sig)
{
while (waitpid( -1, NULL, WNOHANG) < 0)
{
num_procs_creat--;
}
}
int main(int argc, char *argv[])
{
struct sockaddr_in init_addr, client_addr;
char *token, message[ MAX_LENGTH], **newargv = NULL, * line = NULL, str[1024], exec_path[1024], *wd_ptr = NULL;
struct hostent *res;
fd_set readfds;
int num_procs = 0, i, j, master_sock, new_socket, max_sock;
socklen_t client_addr_len = sizeof(client_addr);
pid_t pid;
list_dsm_proc lst = NULL;
dsm_proc_t *listing1 = NULL, *listing2 = NULL;
FILE * fp;
size_t len = 0;
ssize_t read;
if (argc < 3)
{
usage();
}
else
{
/* Mise en place d'un traitant pour recuperer les fils zombies*/
struct sigaction action;
memset( &action, 0, sizeof( struct sigaction));
action.sa_handler = sigchld_handler;
sigaction( SIGCHLD, &action, NULL);
/* lecture du fichier de machines */
wd_ptr = getcwd(str,1024);
sprintf(exec_path,"%s/%s",str,argv[1]);
fp = fopen(exec_path, "r");
if (fp == NULL)
{
exit(EXIT_FAILURE);
}
/*
1- on recupere le nombre de processus a lancer
2- on recupere les noms des machines : le nom de
la machine est un des elements d'identification
*/
while ((read = getline(&line, &len, fp)) != -1)
{
token = strtok(line, "\n");
add_proc(&lst,token);
num_procs++;
}
free(line);
fclose(fp);
/* Socket Creation */
master_sock = do_socket( AF_INET, SOCK_STREAM, IPPROTO_TCP);
init_main_addr( &init_addr);
printf("%s and %u\n", inet_ntoa(init_addr.sin_addr), ntohs(init_addr.sin_port));
do_bind( master_sock, init_addr, sizeof(init_addr));
listen( master_sock, num_procs);
return (0);
/* Son Creation */
listing1 = lst;
for(i = 0; i < num_procs ; i++)
{
/* creation du tube pour rediriger stdout */
//int out[2];
//pipe(out);
/* creation du tube pour rediriger stderr */
//int err[2];
//pipe(err);
pid = fork();
if(pid == -1) ERROR_EXIT("fork");
if (pid == 0) /* Son */
{
// redirection stdout
/*close(out[0]);
dup2(STDOUT_FILENO,out[1]);
close(STDOUT_FILENO);
// redirection stderr
close(err[0]);
dup2(STDERR_FILENO,err[1]);
close(STDERR_FILENO);*/
listing1->pid = getpid();
//printf("name:%s, pid: %i\n",listing1->machine_name, listing1->pid);
/* Creation du tableau d'arguments pour le ssh */
newargv = malloc((argc+4)*sizeof(char*));
for ( j = 0; j < argc+3; j++)
{
newargv[j] = malloc(200*sizeof(char));
}
sprintf(newargv[0], "ssh"); // ssh
sprintf(newargv[1], "%s", listing1->machine_name); // nom de la machine
sprintf(newargv[2], "%s/%s",str,"./bin/dsmwrap");
sprintf(newargv[3], "%s", inet_ntoa(init_addr.sin_addr)); // @IP de la machine
sprintf(newargv[4], "%d", ntohs(init_addr.sin_port)); // Numero du port machine
sprintf(newargv[5], "%s", argv[2]); // prog à executer
if (argc > 3)
{
for (j = 0; j < argc-3; j++)
{
newargv[6+j] = argv[j+3]; // The other arguments
}
}
printf("%s\n",newargv[0] );
printf("%s\n",newargv[1] );
printf("%s\n",newargv[2] );
printf("%s\n",newargv[3] );
printf("%s\n",newargv[4] );
printf("%s\n",newargv[5] );
/* jump to new prog :*/
if (execvp(newargv[0], newargv) == -1)
{
ERROR_EXIT("exec child dsmexec");
}
}
else // Father
{
if (pid > 0){
/* fermeture des extremites des tubes non utiles */
/*close(out[1]);
dup2(out[0],STDOUT_FILENO);
close(err[1]);
dup2(err[0],STDERR_FILENO);*/
num_procs_creat++;
//printf("num_procs_creat: %i\n",num_procs_creat);
listing1 = listing1->next;
}
}
}
FD_ZERO(&readfds); //Clears the socket set
FD_SET(master_sock, &readfds); //Add the server's main socket
max_sock = master_sock;
for (i = 0; i < num_procs ; i++)
{
listing1 = lst;
if (select( max_sock + 1 , &readfds , NULL , NULL , NULL) < 0) // Select a socket where there is "mouvement" or activity
{
ERROR_EXIT("select");
}
if (FD_ISSET(master_sock, &readfds)) // If something happens on the master socket (aka serv_sock), then it means there is an incoming connection
{
/* on accepte les connexions des processus dsm */
new_socket = do_accept( master_sock, &client_addr, &client_addr_len);
/* On recupere le nom de la machine distante */
res = gethostbyaddr(&client_addr.sin_addr, sizeof(client_addr.sin_addr), AF_INET);
/* 1- d'abord la taille de la chaine */
char * distant_mach_name = (char *) malloc((strlen(res->h_name) +1) * sizeof(char));
/* 2- puis la chaine elle-meme */
strcpy(distant_mach_name, res->h_name);
while ( strcmp(listing1->machine_name, distant_mach_name) != 0 ) {
listing1 = listing1->next;
}
/* On recupere le pid du processus distant */
read = read_line( new_socket, message, MAX_LENGTH);
while( listing1 != NULL )
{
if (strcmp(listing1->machine_name, distant_mach_name) == 0 && listing1->connect_info.rank == 0)
{
/* On recupere le numero de port de la socket */
/* d'ecoute des processus distants */
listing1->pid = atoi(message);
listing1->connect_info.rank = i;
listing1->connect_info.dsm_addr = client_addr.sin_addr;
listing1->connect_info.dsm_port_num = client_addr.sin_port;
listing1->sock = new_socket;
FD_SET(new_socket, &readfds);
break;
}
else
{
listing1 = listing1->next;
}
}
if (listing1 == NULL)
{
close(new_socket);
}
memset( message, 0, sizeof(message));
}
}
for (i = 0; i < num_procs ; i++)
{
listing2 = lst;
/* envoi du nombre de processus aux processus dsm*/
sprintf(message, "%i", num_procs_creat);
send_line(listing1->sock, message, sizeof(message));
/* envoi des rangs aux processus dsm */
sprintf(message, "%i", listing1->connect_info.rank);
send_line(listing1->sock, message, sizeof(message));
/* envoi des infos de connexion aux processus */
for (j = 0; j < num_procs; j++) {
if ( strcmp(listing1->machine_name,listing2->machine_name) != 0)
{
sprintf(message, "%i", listing1->connect_info.rank);
send_line(listing2->sock, message, sizeof(message));
sprintf(message, "%s", inet_ntoa (listing1->connect_info.dsm_addr));
send_line(listing2->sock, message, sizeof(message));
sprintf(message, "%i", listing1->connect_info.dsm_port_num);
send_line(listing2->sock, message, sizeof(message));
}
listing2 = listing2->next;
}
listing1 = listing1->next;
}
/* gestion des E/S : on recupere les caracteres */
/* sur les tubes de redirection de stdout/stderr */
/* while(1)
{
je recupere les infos sur les tubes de redirection
jusqu'� ce qu'ils soient inactifs (ie fermes par les
processus dsm ecrivains de l'autre cote ...)
};
*/
/* on attend les processus fils */
/* on ferme les descripteurs proprement */
/* on ferme la socket d'ecoute */
}
exit(EXIT_SUCCESS);
}
|
b4e29f324b2365b7be48cc8c4653d3aaa09c89e0
|
e2c31e128e8994f6c2c1ad23f99e4f9b3ed02df8
|
/comm_code/cbpm_adc_buffer_get_a.c
|
86d509629b10c7d8f56d9eab52d1dc2b02fe66b4
|
[] |
no_license
|
rendinam/CBPM-TSHARC
|
568366acc7a0f518c50f60fd21e56990dd6fbb85
|
7b7b37a475bccb594ed5d2a648a4ee283c91f80b
|
refs/heads/master
| 2023-02-27T19:51:34.876518 | 2021-02-09T17:47:49 | 2021-02-09T17:47:49 | 337,487,858 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 1,662 |
c
|
cbpm_adc_buffer_get_a.c
|
//------------------------------------------------------------------------
// D O N O T E D I T T H I S F I L E
//------------------------------------------------------------------------
// File : cbpm_adc_buffer_get_a.c
// Date Created : Fri Sep 14 14:08:01 2012
//
// Description : This file was automatically generated by the BIParser.
// It provides a standardized accessor function to allow
// retrieval of data values from a collection of identical
// data buffer structures, indexed in a
// <card, timing_block, channel> fashion.
//------------------------------------------------------------------------
#include "cbpm_includes.h"
int cbpm_adc_buffer_get(CBPM_DATA *dp, int card, int tblock, int idx) {
int buf_number = (card*CBPM_MAX_TIMING_BLOCKS*CBPM_MAX_CARD_ADCS_PER_BLOCK) +
(tblock*CBPM_MAX_CARD_ADCS_PER_BLOCK);
int *ptr;
switch (buf_number) {
case (0):
ptr = (int*)&(dp->cbpm_adc_buffer0);
return *(ptr+idx);
break;
case (1):
ptr = (int*)&(dp->cbpm_adc_buffer1);
return *(ptr+idx);
break;
case (2):
ptr = (int*)&(dp->cbpm_adc_buffer2);
return *(ptr+idx);
break;
case (3):
ptr = (int*)&(dp->cbpm_adc_buffer3);
return *(ptr+idx);
break;
case (4):
ptr = (int*)&(dp->cbpm_adc_buffer4);
return *(ptr+idx);
break;
case (5):
ptr = (int*)&(dp->cbpm_adc_buffer5);
return *(ptr+idx);
break;
case (6):
ptr = (int*)&(dp->cbpm_adc_buffer6);
return *(ptr+idx);
break;
case (7):
ptr = (int*)&(dp->cbpm_adc_buffer7);
return *(ptr+idx);
break;
default:
break;
}
return CBI_F_SUCCESS;
}
|
8f7b26c546ffda77c27cd144090ec401fa4cb6f0
|
2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0
|
/fuzzedpackages/RcppTN/src/etn.h
|
ccf88c0d019596fc90bc458fb1d16ca90472376e
|
[] |
no_license
|
akhikolla/testpackages
|
62ccaeed866e2194652b65e7360987b3b20df7e7
|
01259c3543febc89955ea5b79f3a08d3afe57e95
|
refs/heads/master
| 2023-02-18T03:50:28.288006 | 2021-01-18T13:23:32 | 2021-01-18T13:23:32 | 329,981,898 | 7 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 244 |
h
|
etn.h
|
# ifndef ETN_H
# define ETN_H
# include <Rcpp.h>
void etn(Rcpp::NumericVector &Mean,
Rcpp::NumericVector &Sd,
Rcpp::NumericVector &Low,
Rcpp::NumericVector &High,
Rcpp::NumericVector &Exps
) ;
# endif
|
7ff644af134712bcc432792c30882d31d4d558dc
|
38f8330b9178a76c85aed3b04beb1dffc3cf3716
|
/llvm/tools/clang/test/CodeGen/tvm/runtime/c-testsuite/00030.c
|
c863a419cf9174a7c7a1e42a9ed4449f3effdc15
|
[
"MIT",
"NCSA"
] |
permissive
|
EnoRage/TON-Compiler
|
62cb61744756b71737c6a1482d414f35e571636c
|
a16d9976e8f2a87512162dd5415a54a6ace925f8
|
refs/heads/master
| 2020-08-24T23:35:14.486000 | 2019-10-17T08:37:26 | 2019-10-21T21:39:42 | null | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 374 |
c
|
00030.c
|
// RUN: %clang -w -O3 -S -c -target tvm %s -o - | tvm-testrun --no-trace --entry test_entry_point | FileCheck %S/shared.h
int
f()
{
return 100;
}
int
main()
{
if (f() > 1000)
return 1;
if (f() >= 1000)
return 1;
if (1000 < f())
return 1;
if (1000 <= f())
return 1;
if (1000 == f())
return 1;
if (100 != f())
return 1;
return 0;
}
#include "shared.h"
|
ad55bdae80dc892c3ad71fff62289794a251fe68
|
0aef26863f142bef75a0e4aaf7da76fc95e3d8ae
|
/crypto_hash/asconxofv12/ref/constants.h
|
4e6a560343721ea2e62cd8d556171893d24e30de
|
[] |
no_license
|
jedisct1/supercop
|
94e5afadc56ef650d7029774a6b05cfe2af54738
|
7c27338ee73a2bd642ba3359faaec395914175a2
|
refs/heads/master
| 2023-08-02T20:12:39.321029 | 2023-05-30T03:03:48 | 2023-05-30T03:03:48 | 179,046,113 | 23 | 2 | null | null | null | null |
UTF-8
|
C
| false | false | 35 |
h
|
constants.h
|
../../asconhashav12/ref/constants.h
|
d5c44d36c9df8734dfdbef3ad9985f0ce8376715
|
e753f8ab10eb6732f272217169e48ab4754295ee
|
/dns/mydns/files/patch-src_mydns_recursive.c
|
b86c0f2b57dfa155bb9e2071271d1f6d6cc2b5c1
|
[
"BSD-2-Clause"
] |
permissive
|
DragonFlyBSD/DPorts
|
dd2e68f0c11a5359bf1b3e456ab21cbcd9529e1c
|
4b77fb40db21fdbd8de66d1a2756ac1aad04d505
|
refs/heads/master
| 2023-08-12T13:54:46.709702 | 2023-07-28T09:53:12 | 2023-07-28T09:53:12 | 6,439,865 | 78 | 52 |
NOASSERTION
| 2023-09-02T06:27:16 | 2012-10-29T11:59:35 | null |
UTF-8
|
C
| false | false | 409 |
c
|
patch-src_mydns_recursive.c
|
--- src/mydns/recursive.c.orig Mon Apr 30 08:17:52 2007
+++ src/mydns/recursive.c Mon Apr 30 08:22:13 2007
@@ -109,8 +109,7 @@
#endif
/* Send to remote server */
- if ((rv = sendto(t->recursive_fd, query, querylen, 0,
- (struct sockaddr *)&recursive_sa, sizeof(struct sockaddr_in))) != querylen)
+ if ((rv = send(t->recursive_fd, query, querylen, 0)) != querylen)
{
if (errno == EAGAIN)
{
|
f1351cceb540bf6623957239634d852428343ced
|
005697bed15a7c4d4629a9f544b4141ed8adaffb
|
/HackerRank/CompareTheTriplets.c
|
f031b605dc98311a7ed64a1f53e9a4be75879032
|
[] |
no_license
|
javram5985/Curso-de-Algoritmos-con-C
|
0f6d679a2cdacaab06688a0480217996012c4adc
|
e8b6197756b56b65d73b15625414112d7658445c
|
refs/heads/master
| 2020-03-07T14:12:26.400711 | 2018-04-08T08:11:05 | 2018-04-08T08:11:05 | 127,521,143 | 0 | 0 | null | 2018-04-08T08:11:06 | 2018-03-31T10:08:54 |
C
|
UTF-8
|
C
| false | false | 412 |
c
|
CompareTheTriplets.c
|
#include <stdio.h>
int a[3];
int b[3];
int score_a = 0;
int score_b = 0;
void main()
{
scanf("%d" "%d" "%d", &a[1], &a[2], &a[3]);
scanf("%d" "%d" "%d", &b[1], &b[2], &b[3]);
for(int i = 1; i < 4; i++)
{
if(a[i] > b[i])
{
score_a++;
}
else if(b[i] > a[i])
{
score_b++;
}
}
printf("%d %d\n", score_a, score_b);
}
|
56a5a8f67f97612121a84301dded1419cadedb6d
|
5a94e912ee50795d69a73ab3ea2bdee61253dc09
|
/timers.c
|
d06ef3b01dcb8d59f168b47d0525032f89368d6c
|
[] |
no_license
|
dedobbin/attolic_embedded_classes
|
4b910012c269df9420a18be6cc2abd3c879e7e99
|
3ff896e41e04c354d3f23f86d26abbad8bc969bf
|
refs/heads/master
| 2023-04-20T20:03:07.724964 | 2021-04-12T19:04:57 | 2021-04-12T19:04:57 | 357,299,972 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 6,305 |
c
|
timers.c
|
/*
*****************************************************************************
**
** File : main.c
**
** Abstract : Knipperlicht met timer 3.
** Author : R.Slokker
*
*/
/* Includes */
#include <stddef.h>
#include "stm32l1xx.h"
#include "discover_board.h"
/**
**===========================================================================
**
** Abstract: main program
**
**===========================================================================
*/
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
__IO uint16_t CCR1_Val = 18;
static volatile uint32_t TimingDelay;
RCC_ClocksTypeDef RCC_Clocks;
void Init_GPIOs (void);
void RCC_Configuration(void);
void TIM_Config(void);
void Init_GPIOs (void);
void RCC_Configuration(void);
static volatile uint32_t TimingDelay;
RCC_ClocksTypeDef RCC_Clocks;
void Config_Systick()
{
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
}
int main(void)
{
RCC_Configuration();
/* Init I/O ports */
Init_GPIOs ();
/* Init Systick */
Config_Systick();
/* Initializes the LCD glass */
LCD_GLASS_Init();
LCD_GLASS_DisplayString((uint8_t*)"STM32L-DISCOVERY");
LCD_GLASS_ScrollSentence((uint8_t*)" ** Atollic TrueSTUDIO ** ",3,200);
/* Switch on the leds at start */
GPIO_HIGH(LD_PORT,LD_GREEN);
GPIO_HIGH(LD_PORT,LD_BLUE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC| RCC_AHBPeriph_GPIOD| RCC_AHBPeriph_GPIOE| RCC_AHBPeriph_GPIOH, ENABLE);
Init_GPIOs();
//Zet de groene led aan
GPIOB->ODR=0x80;
/* TIM Configuration */
TIM_Config();
while (1);
}
void TIM_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
uint16_t prescalervalue;
/* TIM3 clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
/* -----------------------------------------------------------------------
TIM3 Configuration: Output Compare Timing Mode:
In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1),
since APB1 prescaler is different from 1.
TIM3CLK = 2 * PCLK1
PCLK1 = HCLK / 4
=> TIM3CLK = HCLK / 2 = SystemCoreClock /2
Note:
SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file.
Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate()
function to update SystemCoreClock variable value. Otherwise, any configuration
based on this variable will be incorrect.
----------------------------------------------------------------------- */
/* Compute the prescaler value */
prescalervalue = (uint16_t) ((SystemCoreClock / 2) / 500000) - 1;
/* Time base configuration */
// Vul in de maximale waarde van het timer counter register
TIM_TimeBaseStructure.TIM_Period = 0XFFFF;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
/* Prescaler value is loaded immediate */
TIM_PrescalerConfig(TIM3, prescalervalue, TIM_PSCReloadMode_Immediate);
/* Output Compare Timing Mode configuration: Channel1 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Disable;
TIM_OC1Init(TIM3, &TIM_OCInitStructure);
/* Timer interrupt bij een update event */
TIM_ITConfig(TIM3,TIM_IT_Update, ENABLE);
/* TIM3 enable counter */
TIM_Cmd(TIM3, ENABLE);
/* Enable the TIM3 gloabal Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void TIM3_IRQHandler(void)
{
TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
GPIO_TOGGLE(LD_PORT,LD_BLUE);
GPIO_TOGGLE(LD_PORT,LD_GREEN);
}
void RCC_Configuration(void)
{
/* Enable the GPIOs Clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC| RCC_AHBPeriph_GPIOD| RCC_AHBPeriph_GPIOE| RCC_AHBPeriph_GPIOH, ENABLE);
/* Enable comparator clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_COMP | RCC_APB1Periph_LCD | RCC_APB1Periph_PWR,ENABLE);
/* Enable SYSCFG */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG , ENABLE);
/* Allow access to the RTC */
PWR_RTCAccessCmd(ENABLE);
/* Reset Backup Domain */
RCC_RTCResetCmd(ENABLE);
RCC_RTCResetCmd(DISABLE);
/*!< LSE Enable */
RCC_LSEConfig(RCC_LSE_ON);
/*!< Wait till LSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET)
{}
/*!< LCD Clock Source Selection */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
}
void Init_GPIOs (void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure User Button pin as input */
GPIO_InitStructure.GPIO_Pin = USER_GPIO_PIN;
//GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure the GPIO_LED pins LD3 & LD4*/
GPIO_InitStructure.GPIO_Pin = LD_GREEN|LD_BLUE;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
/**
* @brief Inserts a delay time.
* @param nTime: specifies the delay time length, in 10 ms.
* @retval None
*/
void Delay(uint32_t nTime)
{
TimingDelay = nTime;
while(TimingDelay != 0);
}
/**
* @brief Decrements the TimingDelay variable.
* @param None
* @retval None
*/
void TimingDelay_Decrement(void)
{
if (TimingDelay != 0x00)
{
TimingDelay--;
}
}
#
|
39a4793afe951f1e6c28f45061fa05f093185258
|
0c369ff799355782e620c8f55925fafa811d0f74
|
/Pods/Headers/Public/CloudantToolkit/CloudantToolkit/CDTQueryCursor.h
|
cb76289dd5b5fc81beb1b287bcab22c42d45b5ea
|
[] |
no_license
|
CanKer/Bluemix
|
bbd8f282982b159ceea5a191532d2edf7b1595f5
|
94b2585ca4c694c162bfdc8ecc55d25e531161f9
|
refs/heads/master
| 2021-01-13T01:03:10.104408 | 2015-09-25T01:18:00 | 2015-09-25T01:18:00 | 43,012,778 | 1 | 1 | null | null | null | null |
UTF-8
|
C
| false | false | 89 |
h
|
CDTQueryCursor.h
|
../../../../CloudantToolkit/Frameworks/CloudantToolkit.framework/Headers/CDTQueryCursor.h
|
5f37f4fea44329d3007899a1be2baa9832129774
|
cacecfaf0054e2190e5788e1c78dbb0ed6e4242b
|
/selvams.c
|
20b8d676f7f1ab4ac55be62087ab7229e6360447
|
[] |
no_license
|
sELVAmVsB/selvam77
|
18e535b80548ae5eeea2b9a0438eec486d19f120
|
fd7dd908509c3b0c4ab803bdcf9b9500f713775c
|
refs/heads/master
| 2021-05-10T12:37:08.702334 | 2018-03-05T10:35:37 | 2018-03-05T10:35:37 | 118,447,324 | 0 | 0 | null | null | null | null |
UTF-8
|
C
| false | false | 90 |
c
|
selvams.c
|
#include<stdio.h>
#include<conio.h>
{
int =a,b
printf ("enter the valu");
scang("%d",a,b)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.