Пример #1
0
void test_fast_read_set04(CuTest *tc){
    short int i, j;
    fast_read_set set;
    printf("\nFast-read-set test#04 - elements 0-19: unique_insert\nmarked: 0-14 repeated 50 times\narray read by is_marked:\n");
    construct_fast_read_set(&set, 20);
    for(j = 0; j < 50; ++j){
        for(i = 0; i < 15; ++i){
            set_mark(&set, i);
        }
    }
    for(i = 0; i < 20; ++i){
        printf("%d ", (int)is_marked(&set, i));
    }
    printf("\n\tThere should be no repetitions in the tree;\t");
    RB_display_keys_in_order(&set.tree);

    reset_marks(&set);
    printf("Now all cells should be reset:\n");
    for(i = 0; i < 20; ++i){
        printf("%d ", (int)is_marked(&set, i));
    }
    printf("\n");
    RB_display_keys_in_order(&set.tree);

    destroy_fast_read_set(&set);
}
Пример #2
0
// Used by scavengers
inline void oopDesc::forward_to(oop p) {
  assert(Universe::heap()->is_in_reserved(p),
         "forwarding to something not in heap");
  markOop m = markOopDesc::encode_pointer_as_mark(p);
  assert(m->decode_pointer() == p, "encoding must be reversable");
  set_mark(m);
}
Пример #3
0
void
chunk_registry::mark (void* ptr)
{
  auto header = find_chunk (ptr);
  assert (header && "Must be a valid ptr");
  header->set_mark (ptr);
}
Пример #4
0
void test_fast_read_set01(CuTest *tc){
    short int i;
    fast_read_set set;
    printf("\nFast-read-set test#01 - elements 0-19: set_mark\nmarked: 0, 2, 5, 12, 19\n\tarray read directly:\n");
    construct_fast_read_set(&set, 20);
    set_mark(&set, 5);
    set_mark(&set, 0);
    set_mark(&set, 2);
    set_mark(&set, 12);
    set_mark(&set, 19);
    for(i = 0; i < 20; ++i){
        printf("%d ", (int)set.array[i]);
    }
    printf("\n");
    RB_display_keys_in_order(&set.tree);
    destroy_fast_read_set(&set);
}
Пример #5
0
void test_fast_read_set02(CuTest *tc){
    short int i;
    fast_read_set set;
    printf("\nFast-read-set test#02 - elements 0-19: is_marked\nmarked: 3, 4, 8, 14, 18\n\tarray read by is_marked:\n");
    construct_fast_read_set(&set, 20);
    set_mark(&set, 18);
    set_mark(&set, 3);
    set_mark(&set, 8);
    set_mark(&set, 4);
    set_mark(&set, 14);
    for(i = 0; i < 20; ++i){
        printf("%d ", (int)is_marked(&set, i));
    }
    printf("\n");
    RB_display_keys_in_order(&set.tree);
    destroy_fast_read_set(&set);
}
Пример #6
0
void
set_spec_bookmark(const char mark, const char directory[], const char file[])
{
	if(char_is_one_of(spec_bookmarks, mark))
	{
		set_mark(mark, directory, file, time(NULL), 1);
	}
}
Пример #7
0
void find_next_collision(level_data *level, short int index,
                         fast_read_set *primitive_done, fast_read_set *movable_done, long double time_passed){
    collision_data new_coll;
    int i, j, k;
    level->movable_objects[index].coll_with_fixed.time = EMPTY_COLLISION_TIME;
    for(i = level->movable_objects[index].zones[0]; i <= level->movable_objects[index].zones[2]; ++i){
        for(j = level->movable_objects[index].zones[1]; j <= level->movable_objects[index].zones[3]; ++j){
            for(k = 0; k < level->zones[i][j].number_of_primitives; ++k){
                if(!is_marked(primitive_done, level->zones[i][j].primitives[k])){
                    set_mark(primitive_done, level->zones[i][j].primitives[k]);
                    new_coll = get_collision_with_primitive(&level->movable_objects[index],
                                                            &level->primitive_objects[level->zones[i][j].primitives[k]]);
                    new_coll.time += time_passed;
                    if(new_coll.time >= 0 && new_coll.time <= 1){
                        if(new_coll.time < level->movable_objects[index].coll_with_fixed.time){
                            new_coll.who = index;
                            new_coll.with = level->zones[i][j].primitives[k];
                            level->movable_objects[index].coll_with_fixed = new_coll;
                        }
                    }
                }
            }
        }
    }
    reset_marks(primitive_done);

    set_mark(movable_done, index);
    for(i = level->movable_objects[index].zones[0]; i <= level->movable_objects[index].zones[2]; ++i){
        for(j = level->movable_objects[index].zones[1]; j <= level->movable_objects[index].zones[3]; ++j){
            in_order_check_collision(level, movable_done,
                                            index,
                                            level->zones[i][j].movable.root,
                                            level->zones[i][j].movable.nil,
                                            time_passed);
        }
    }
    reset_marks(movable_done);

    collision_min_for_object(level, index);

    //push on queue  //heap checks if who < with and does necessary exchanges
    if(level->movable_objects[index].next_collision->time <= 1 &&
       level->movable_objects[index].next_collision->time >= 0){
        heap_insert(&level->collision_queue, level->movable_objects[index].next_collision);
    }
}
Пример #8
0
inline void oopDesc::incr_age() {
  assert(!is_forwarded(), "Attempt to increment age of forwarded mark");
  if (has_displaced_mark()) {
    set_displaced_mark(displaced_mark()->incr_age());
  } else {
    set_mark(mark()->incr_age());
  }
}
Пример #9
0
int
set_user_bookmark(const char mark, const char directory[], const char file[])
{
	if(!is_user_bookmark(mark))
	{
		status_bar_message("Invalid mark name");
		return 1;
	}

	set_mark(mark, directory, file, time(NULL), 0);
	return 0;
}
Пример #10
0
void mark_node_ptrs(sl_node_t *n) {
  int i;
  sl_node_t *n_next;
	
  for (i=n->toplevel-1; i>=0; i--) {
    do {
      n_next = n->next[i];
      if (is_marked((uintptr_t)n_next))
        break;
    } while (!ATOMIC_CAS_MB(&n->next[i], n_next, set_mark((uintptr_t)n_next)));
  }
}
Пример #11
0
void
setup_user_bookmark(const char mark, const char directory[], const char file[],
		time_t timestamp)
{
	if(is_user_bookmark(mark))
	{
		set_mark(mark, directory, file, timestamp, 1);
	}
	else
	{
		status_bar_errorf("Only user's bookmarks can be loaded, but got: %c", mark);
	}
}
Пример #12
0
void in_order_check_collision(level_data *level, fast_read_set *movable_done,
                              short int who, RB_node *node, RB_node *nil, long double time_passed){
    if(node != nil){
        in_order_check_collision(level, movable_done, who, node->left, nil, time_passed);

        if(!is_marked(movable_done, node->key)){
            set_mark(movable_done, node->key);
            get_and_check_mov_coll_if_valid(level, who, node->key, time_passed);
        }

        in_order_check_collision(level, movable_done, who, node->right, nil, time_passed);
    }
}
Пример #13
0
zoom_start()
/* Starts the first part of zooming--moving the red cross to the upper right
   corner of the area to zoom.  This gets called by menu choice "zoom in". */
{
	int x, y;

	if ( ! zoom_ok () )
	{
		return;
	}
	zoom_push ();

	x1 = xorg; x2 = xend;
	y1 = yorg; y2 = yend;

	x = dev_x;
	y = dev_y;

	x -= 10; y += 10;

	if ( x >= xorg && x <= xend )
		x1 = x;

	if ( y >= yorg && y <= yend )
		y1 = y;

	set_mark();
	mask_red ();

	mask_line ( x1 - 5, y1, x1 + 5, y1 );
	mask_line ( x1, y1 + 5, x1, y1 - 5 );
	XFlush ( x_display );

	last_x1 = x1; last_y1 = y1;

	zooming = 1;
	set_zoom_menus( True );
}
Пример #14
0
inline int
mark_node_ptrs(sl_node_t *n)
{
  int i, cas = 0;
  sl_node_t* n_next;
	
  for (i = n->toplevel - 1; i >= 0; i--)
    {
      do
      	{
      	  n_next = n->next[i];
      	  if (is_marked((uintptr_t)n_next))
      	    {
	      cas = 0;
      	      break;
      	    }
	  cas = ATOMIC_CAS_MB(&n->next[i], GET_UNMARKED(n_next), set_mark((uintptr_t)n_next));
      	} 
      while (!cas);
    }

  return (cas);	/* if I was the one that marked lvl 0 */
}
Пример #15
0
long get_marked_ref(long w) {
    return set_mark(w);
}
Пример #16
0
inline void   oopDesc::init_mark()                 { set_mark(markOopDesc::prototype()); }
Пример #17
0
void memOopClass::set_identity_hash(smi h) {
  set_mark(mark()->set_hash(h));
}
Пример #18
0
static LISP lset_mark(LISP mark)
{
	set_mark(w_list, make_position(POSITION_ROW(mark),
					POSITION_COL(mark)));
	return NIL;
}
Пример #19
0
/**
 * Mouse motion callback
 *
 */
gint
scorearea_motion_notify (GtkWidget * widget, GdkEventButton * event)
{
  DenemoProject *gui = Denemo.project;
  if (gui == NULL || gui->movement == NULL)
    return FALSE;
  if (Denemo.scorearea == NULL)
    return FALSE;
  gint allocated_height = get_widget_height (Denemo.scorearea);
  gint line_height = allocated_height * gui->movement->system_height;
  if(dragging_outside)
    {
          gint incrx, incry;
          incrx=incry=0;
          if(((gint)((last_event_x - event->x_root)/gui->movement->zoom)) != 0)
            {
                incrx = -(last_event_x - event->x_root)/gui->movement->zoom;
                last_event_x = event->x_root;
            }
          if( ((gint)((last_event_y - event->y_root)/gui->movement->zoom)) != 0)
            {
                incry = -(last_event_y - event->y_root)/gui->movement->zoom;
                last_event_y = event->y_root;
            }
        if((dragging_outside==DRAG_DIRECTION_RIGHT) && (incrx > 1)
            || ((dragging_outside==DRAG_DIRECTION_LEFT) && (incrx < -1))
            || ((dragging_outside==DRAG_DIRECTION_UP) && (incry < 0))
            || ((dragging_outside==DRAG_DIRECTION_DOWN) && (incry > 0)))
            extend_selection(dragging_outside);
    return TRUE;
    }
  if (event->y < 0)
    event->y = 0.0;
  gint line_num = ((int) event->y) / line_height;


   if (last_directive && (GDK_SHIFT_MASK & event->state) && (GDK_CONTROL_MASK & event->state))
      {
          gint incrx, incry;
          incrx=incry=0;
          if(((gint)((last_event_x - event->x_root)/gui->movement->zoom)) != 0)
            {
                incrx = (last_event_x - event->x_root)/gui->movement->zoom;
                last_event_x = event->x_root;
            }
          if( ((gint)((last_event_y - event->y_root)/gui->movement->zoom)) != 0)
            {
                incry = (last_event_y - event->y_root)/gui->movement->zoom;
                last_event_y = event->y_root;
            }

        if(last_directive->graphic)
            {
                last_directive->gx -= incrx;
                last_directive->gy -= incry;
            }
        else
            {
                last_directive->tx -= incrx;
                last_directive->ty -= incry;
            }
        draw_score_area();

        return TRUE;
      }



  if(gui->movement->recording && dragging_audio)
    {
        if(gui->movement->recording->type == DENEMO_RECORDING_MIDI)
        {
            #if 0
            //This is moving only the NoteOn, so it could be moved later than the note off, and indeed later than a later note in the stream
            //- quite a bit more work needed to drag MIDI to correct the timing.
            smf_event_t *midievent;
            GList *marked_onset = gui->movement->marked_onset;
            if(marked_onset)
                {
                midievent = ((DenemoRecordedNote *)marked_onset->data)->event;
                gint shift =  2500*(event->x_root - last_event_x)/gui->movement->zoom;
                g_debug (" %f (%f %f)",shift/(double)gui->movement->recording->samplerate,
                    midievent->time_seconds,
                    ((DenemoRecordedNote *)marked_onset->data)->timing/(double)gui->movement->recording->samplerate) ;

                ((DenemoRecordedNote *)marked_onset->data)->timing += shift;

                midievent->time_seconds += shift/(double)gui->movement->recording->samplerate;
                }
            #endif
            g_warning("No drag for MIDI yet");
            return TRUE;
        }

        gui->movement->recording->leadin -= 500*(event->x_root - last_event_x)/gui->movement->zoom;//g_debug("%d %d => %d\n", (int)(10*last_event_x), (int)(10*event->x_root), (int)(10*last_event_x) - (int)(10*event->x_root));
        last_event_x = event->x_root;
        update_leadin_widget ( gui->movement->recording->leadin/(double)gui->movement->recording->samplerate);
        gtk_widget_queue_draw(Denemo.scorearea);
        return TRUE;
    }
  if(gui->movement->recording && dragging_tempo)
    {
        gdouble change = (event->x_root - last_event_x)/gui->movement->zoom;
        last_event_x = event->x_root;
        struct placement_info pi;
        get_placement_from_coordinates (&pi, event->x, 0, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]);
        change /= pi.measure_number;
        update_tempo_widget ( change);
        set_tempo ();
        score_status (Denemo.project, TRUE);
        exportmidi (NULL, gui->movement);
        gtk_widget_queue_draw(Denemo.scorearea);
        return TRUE;
    }
#define DENEMO_MINIMUM_SYSTEM_HEIGHT (0.01)


  if (dragging_separator)
    {
      gui->movement->system_height = event->y / get_widget_height (Denemo.scorearea);
      if (gui->movement->system_height < DENEMO_MINIMUM_SYSTEM_HEIGHT)
        gui->movement->system_height = DENEMO_MINIMUM_SYSTEM_HEIGHT;
      if (gui->movement->system_height > 1.0)
        gui->movement->system_height = 1.0;
      scorearea_configure_event (Denemo.scorearea, NULL);
      draw_score_area();
      return TRUE;
    }

  if (line_height - ((int) event->y - 8) % line_height < 12)
    gdk_window_set_cursor (gtk_widget_get_window (Denemo.window), gdk_cursor_new (GDK_SB_V_DOUBLE_ARROW));
  else
    gdk_window_set_cursor (gtk_widget_get_window (Denemo.window), gdk_cursor_new (GDK_LEFT_PTR));       //FIXME? does this take time/hog memory

  transform_coords (&event->x, &event->y);
  //g_debug("Marked %d\n", gui->movement->markstaffnum);


  if (gui->lefts[line_num] == 0)
    return TRUE;




  if (lh_down || (selecting && gui->movement->markstaffnum))
    {
      struct placement_info pi;
      pi.the_staff = NULL;
      if (event->y < 0)
        get_placement_from_coordinates (&pi, event->x, 0, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]);
      else
        get_placement_from_coordinates (&pi, event->x, event->y, gui->lefts[line_num], gui->rights[line_num], gui->scales[line_num]);
      if (pi.the_staff == NULL)
        return TRUE;            //could not place the cursor
      if (pi.the_measure != NULL)
        {                       /*don't place cursor in a place that is not there */
          change_staff (gui->movement, pi.staff_number, pi.the_staff);
          gui->movement->currentmeasurenum = pi.measure_number;
          gui->movement->currentmeasure = pi.the_measure;
          gui->movement->currentobject = pi.the_obj;
          gui->movement->cursor_x = pi.cursor_x;
          gui->movement->cursor_appending = (gui->movement->cursor_x == (gint) (g_list_length ((objnode *) ((DenemoMeasure*)gui->movement->currentmeasure->data)->objects)));

          set_cursor_y_from_click (gui, event->y);
          if (lh_down & !selecting)
            {
              if (gui->movement->markstaffnum)
                set_point (NULL, NULL);
              else
                set_mark (NULL, NULL);
              selecting = TRUE;
            }
          calcmarkboundaries (gui->movement);
          if (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK))
            perform_command (event->state, GESTURE_MOVE, event->state & GDK_BUTTON1_MASK);

          /* redraw to show new cursor position  */
          draw_score_area();
        }
    }

  if (Denemo.project->midi_destination & MIDICONDUCT)
    {
      advance_time (0.01);
      return TRUE;
    }
  return TRUE;
}
Пример #20
0
void oopDesc::init_mark() {
  set_mark(markOopDesc::prototype_for_object(this));
}